Generating a Java Client using WAS IBM-CICS

This section demonstrates the use of WebSphere Developer for System z (WD/z) to generate a Web service client and run it in an application server. WD/z generates all the required Java classes to create a Web service request and to receive a Web service response. It also builds a very basic graphical user interface to interact with those classes. RAD users will be able to take advantage of this facility as the wizard is part of the RAD Web service features. As WD/z is built on RAD, this facility is also available under WD/z.

For this example, we generate a client to invoke the GetHash Web service. The only input required is the GetHash.wsdl.

Import the wsdl

The wsdl needs to be in the WD/z work space. If you do not already have a local copy of the wsdl, import the wsdl using File → Import, and then select the import source. Follow the wizard to complete the import.

Start the application server

Start the server before we start to generate the Web client using the wizard because it can take several minutes to start the WebSphere Application Server.

To start the server, select it in the Servers view. Go to Window → Show View → Other, and select Server → Servers, and click OK. This is seen in Figure.

Select the Server view

Select the Server view

In the Servers view, right-click the server name, and select Start. This begins the server startup, and progress can be seen in the console view that is dynamically opened. The server view shows the status as in Figure.

The Server view showing startup

The Server view showing startup

A successful startup of the server will show a State of Started and a Status of Synchronized. The Console view shows the following message:

WSVR0001I: Server server1 open for e-business

Generate the client

We are now going to generate a proxy client to test the Web service.

  1. Right-click the wsdl file in the Project explorer view.
  2. Select Web Services → Generate Client.
  3. This displays the Web services wizard. There is much richer functionality here than just generating a test client. The slide bar allows you to select the stages of Web service client development. The wizard will take you through the stages Develop - Assemble - Deploy - Install - Test.

    We are only interested in testing the Web service using a proxy Java client, so slide the bar to the Test position, as shown in Figure.

    There are also options in the Configuration section of the panel in Figure to select the server, runtime, and to change the Web service project name and Web service EAR name that are auto-generated. Because this is just a unit test we left the default of WebServiceProject and WebServiceProjectEAR.

    Web Services wizard

    Web Services wizard

    1. Select Next.
    2. On the Web Service Proxy page, select Next.
    3. The Web Service Client test page in Figure 8-6 shows all the methods that were generated for the client. Ensure that the following boxes are checked:
      • Test the generated proxy
      • Run test on server
    4. Click Finish.

    Web Service Client Test

    Web Service Client Test

  4. The Wizard then opens up a Web browser in the work space in which the methods that were created are listed and can be tested. Figure shows the method that we are testing is ITSOGH03Operation.
  5. Testing the Proxy Client

    Testing the Proxy Client

  6. Fill in some values, and click Invoke.

The result is seen in Figure.

Successful Test Result

Successful Test Result

This test was successful.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

IBM-CICS Topics