Testing the SyncCustomer Web service

In this lesson, you are testing your new Web service with a Java application. This application uses the content of the input.xml file as the body of the Web service request and makes the request. When the response is received, the application prints out the SOAP body of the Web service response.

About this task

This sample uses the OAGIS ConfirmBOD schema to represent the result of the Web service request. The standard JAX-RPC Web service tooling can have difficulties when generating the appropriate Java code to represent a client for this Web service. The JAX-WS 2.0 specification is designed to handle these limitations, however, there is an alternative approach to use the Eclipse Modeling Framework and SOAP binding options to generate Java clients. However, to quickly test the Web service, SAAJ can be used to create a quick test client for the newly created Web service.

Executing the Java application

When executing this application with the same input.xml file, the success scenario of creating a user can occur:

Procedure

  1. Download and extract the sample InboundWebServiceTutorial.zip file to a temporary directory.
  2. Open WebSphere Commerce Developer and switch to the Java perspective.
  3. In the Package Explorer view, select File > New > Project.
  4. Select Java Project; click Next.
  5. In the Project name field, enter SyncCustomerTest; click Finish.
  6. In the Package Explorer view, right-click the SyncCustomerTest project; select New > Package.
  7. In the Name field, enter com.mycompany.webservice; click Finish.
  8. In the Package Explorer view, navigate to SyncCustomerTest/com.mycompany.webservice.
  9. Right-click com.mycompany.webservice; select Import.
  10. Expand General; select File system. Click Next.
  11. Click the Browse button to the right of the From directory field.
  12. Navigate to the directory where you extracted SyncCustomerTest.java and input.xml from the sample InboundWebServiceTutorial.zip file and click OK.
  13. Select SyncCustomerTest.java and input.xml files from the list; click Finish to import the file.
  14. Start or restart the WebSphere Commerce Test Server.
  15. Right-click the WebSphere Commerce Test Server and select Publish.
  16. Set up a TCP/IP Monitor in WebSphere Commerce Developer. You use this TCP/IP Monitor to observe the request and response documents traveling to and from the WebSphere Commerce service you created. To create a TCP/IP Monitor to forward requests to WebSphere Commerce:
    1. Select Window > Preferences.
    2. From the Preferences panel, expand Run/Debug > TCP/IP Monitor.
    3. Click Add.
    4. Type the following information:
      • Local monitoring port:81.
      • Hostname: The hostname of the WebSphere Commerce Server where the Project service is running.
      • Port:80 for WebSphere Commerce Developer
    5. Click OK.
    6. Select the created TCP/IP Monitor.
    7. Click Start.
    8. Click OK.
    9. Select Window > Show View > Other. Expand Debug; select TCP/IP Monitor and click OK.
  17. In the Enterprise Explorer view, verify that there are no compilation errors in all projects.
  18. Right-click SyncCustomerTest.java; select Run As > Java Application.
  19. View the Request and Response panes of the TCP/IP Monitor.

    If you see a <oa:BODSuccessMessage> entry in your output, then you have successfully created a Web SyncCustomer service. Ensure that your TCP/IP Monitor panes resemble the following image: Successful OAGIS inbound web service

    When executing the application with the same input.xml a second time, the failure scenario will occur because the logon id of the user is already specified. By executing the application twice both types of responses can be tested. After re-executing the application, you should receive a <oa:BODFailureMessage> entry in your output. Ensure that the error response that displays resembles the following image: Error response OAGIS web service

    You have successfully testing your response messages for you inbound Web service.