Developing iSeries Web services without source files

You can use the Program Call wizard to create a Java bean and PCML file from an iSeries program or service program procedure, and then use the Web Services wizard to create a Web service from the Java bean and PCML file.

Using the Program Call wizard to generate a Java bean and PCML file:

  1. Open a Web perspective.
  2. Create a new Dynamic Web project.
  3. In the Project Explorer, select the project.
  4. In the workbench menu bar, click the Create Program Call Bean icon Create Program Call Bean icon (picture of server). This launches the Program Call wizard. If you happen to have a PCML file containing the definitions for the iSeries program already, you can import it into the wizard to create the Java bean. Otherwise, use the wizard to create program and parameter definitions:
    1. In the Add Program page, enter a name you want to give to your Java bean, the name of the program object, and the name of the library where it is found. You can click Browse to look up the program that you want to call from your iSeries server.
    2. Click OK. This defines the program or procedure that you want to call.
    3. In the Add Parameter page, for each parameter, enter its name, length, data type, and usage. Click OK.
  5. Click Next to proceed to the next page of the wizard.
  6. In the Package field, name the package where you want the files created. A new package name is acceptable.
  7. Clear the Java Application check box, and make sure the Services check box is selected.
  8. Click Next to enter configuration information to be saved in the runtime configuration file.
    1. Under Authentication, enter values for Host name, User ID, and Password.
    2. Under Library list, type the library where the iSeries program is kept and click Add.
  9. Click Finish.

The Program Call wizard generates three classes. One of the classes is a Java bean which can be used by the Web Services wizard to create a Web service. Its name is <YourBeanName>Services.java. The other two classes are named <YourBeanName>Input.java and <YourBeanName>Result.java. These classes are required by the Java bean class for input and output parameters.

Using the Web Services wizard to create a Web service from the Java bean and PCML file:

For every program that you define in the Program Call wizard, two methods are generated. You can use either one of the methods to get the data returned from the remote program call.

  • The first method returns the output data in XML format. The Web services client can retrieve the data by parsing the XML string.
  • The second method returns the output data in the <YourBeanName>Result.java class. The Web services client can retrieve data using the getter methods from the class.
Now you can use the Web Services wizard to create a Web service from the classes created by the Program Call wizard.
  1. In the Project Explorer, under Java Resources and the package name, right-click <YourBeanName>Services.java.
  2. Select New > Other > Web Services > Web Service. (You might have to select the Show all wizards check box.)
  3. Click Next.
  4. For Web service type, Java bean Web Service should be already selected.
  5. Optional:
    • Select Generate a proxy.  The Java bean client proxy that is generated provides a remote procedure call interface to the Web service.
    • Select Test the Web service. This allows you to test the Web service in the Web Service Explorer before a proxy is generated.
  6. Click Next.
  7. On the Object Selection page, browse to <YourBeanName>Services. ClickNext.
  8. Adjust your deployment configuration settings, if necessary. In particular, you need to change the default entry in the Client project EAR field to something different from the Server project EAR name, for instance ClientDefaultEAR. Click Next.
  9. Click OK. Click Next.
  10. Click Deselect All, then select the methods with names that begin with the contents of the Java bean name field in the Program Call wizard. Click Next.
  11. Optional: On the Select Test Facility page, select Web Services Explorer. Click Next.
  12. Optional: Select Generate proxy. Click Next.
  13. Optional: Select Test the generated proxy and Run test on server. Select this check box if you want to run the Web service immediately. Otherwise, clear the check box. The sample is still created and saved for later use. This is helpful if you want to revisit your runtime configuration settings. To run later, right-click on the TestClient.jsp file in your Web project and select Run on Server.
  14. Click Finish.

The Web browser is launched. If you selected Generate proxy, the WebSphere test environment executes a sample JSP that the Web Services wizard creates to test the Web service.

If there is a complex structure in the PCML, the Web Services wizard might not be able to generate the Test Client properly. You can use the Web Services Explorer to test the generated Web Services. Right-click on the generated WSDL file in the WebContent/wsdl folder, then select Web Services > Test with Web Services Explorer.