Developing IBM i Web services without source files

You can use the Program Call wizard to create a Java™ bean and PCML file from an IBM® i 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:

Before you begin

About this task

Procedure

  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. This launches the Program Call wizard. If you happen to have a PCML file containing the definitions for the IBM i 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 IBM i 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. Make sure that the Web 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. Click the Library list tab, and in the Library field, type the library where the IBM i program is kept and click Add.
  9. Click Finish.

Results

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 YourBeanNameServices.java. The other two classes are named YourBeanNameInput.java and YourBeanNameResult.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:

Before you begin

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 YourBeanNameResult.java class. The Web services client can retrieve data using the getter methods from the class.

About this task

Now you can use the Web Services wizard to create a Web service from the classes created by the Program Call wizard.

Procedure

  1. In the Project Explorer, under Java Resources and the package name, select YourBeanNameServices.java.
  2. Select File > 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, Bottom up Java bean Web Service should be highlighted. If not, select it from the drop-down list.
  5. Select the stages of the Web services development that you want to complete using the slider:
    • Develop: this develops the WSDL definition and implementation of the Web Service. It includes such tasks as creating modules, which will contain the generated code, WSDL files, deployment descriptors, and Java files when appropriate.
    • Assemble: this ensures that the project that hosts the Web Service or client is associated to an EAR when required by the target application server.
    • Deploy: this creates the deployment code for the service.
    • Install: this installs and configures the Web module and EARs on the target server.
    • Start: this starts the server once the service has been installed on it. The server-config-wsdd file is generated.
    • Test: this provides various options for testing the service, such as using the Web Service Explorer or sample JSP files.
  6. The Server option displays the default server. To deploy your service to a different server, click Server and specify the server that you want to use.
  7. The Web service runtime displays the default runtime. To deploy your service to a different runtime, click Web service runtime and specify the runtime that you want to use.
  8. The Service project option displays the project containing the project selected in your workspace. To specify a different project and EAR file, click the Service project link. Ensure that the project selected as the Client Web Project is different than the Service Web Project, or the service will be overwritten by the client's generated artifacts.
  9. If you want to create a client, select the type of proxy to be generated and repeat the above steps for the client.
  10. Select the Publish the Web service check box if you want to launch the Web Services Explorer to publish your Web service to a UDDI registry.
  11. Select the Monitor the Web service check box to send the Web service traffic through the TCP/IP monitor, which allows you to watch the SOAP traffic generated by the Web service, and to test this traffic for WS-I compliance of the specified Service project. As an alternative, you can manually set up a TCP/IP monitor.
  12. Click Next to go to the Service Endpoint Interface Selection page.
  13. Click Next to go to the Web Service Java Bean Identity page.
  14. Click Next. If the Start server wizard page displays, click the Start server button and when the server has started, click Finish.
  15. On the Test Web Service page, select Web Services Explorer in the Test facility field.
  16. Click Finish to launch the Web service in the browser. You can close the browser page after testing your Web service.
  17. You can run the Web service later by right-clicking TestClient.jsp in your Web project and select Run As > Run on Server.

Results


Feedback