Previous Topic: Tutorial 7 - Test an Enterprise JavaBean (EJB)Next Topic: Tutorial 9 - Examine and Test a Database


Tutorial 8 - Test a Web Service

In this tutorial, you use the Web Service Execution (XML) test step to call web service operations in a test case. You then test the request and response. These web service operations provide the same functionality as the equivalent method calls in the EJB used in Tutorial 7.

Tutorial Tasks

In this tutorial, you:

Prerequisites

Step 1 - Create a Test Case

Follow these steps:

  1. Right-click on the Tests folder in the Project panel, and select Create New Test Case.
  2. Set the file name to tutorial8.
  3. Click Save.
  4. In the Project panel, right-click on project.config and select Make active.

Step 2 - Add a Web Service Execution (XML) Test Step

The Web Service Execution (XML) test step enables you to execute an operation on a SOAP-based web service.

Follow these steps:

  1. Click the tutorial8a tab.
  2. Click LISA--icon_image_whiteplussignbluecircle Add Step.
  3. Select Web/Web Services and select Web Service Execution (XML).

    A Web Service step is added to the model editor.

  4. To open the Web Service Execution (XML) editor, double-click the Web Service step.

    Screenshot of Web Service Execution (XML) editor for Tutorial 7

  5. Click New Document.

Step 3 - Create a Web Service Client

Now specify the operation to be called, and create a SOAP message to send to the operation.

Follow these steps:

  1. In the WSDL URL field, enter the following location.

    Note: The WSSERVER and WSPORT properties represent the server and port.

    http://localhost:8080/itko-examples/services/UserControlService?wsdl 
    
    
  2. In the Service field, select UserControlServiceService.
  3. In the Port field, select UserControlService.
  4. In the Operation field, select the addUser operation.
  5. In the On Error field, select Abort the Test.

    DevTest uses this criteria to build the web service client. The Visual XML editor shows a graphical view of the SOAP message.

    Screenshot of Visual XML editor for Tutorial 8

  6. Save the test case.

Step 4 - Execute the Web Service Request

Follow these steps:

  1. Click LISA--icon_image_rightarrowingreencircle Execute WS Request.

    The test is executed.

Step 5 - View the Request and Response

The Request tab shows the resulting request data that was sent after any post processing (for example, substituting DevTest properties). The Response tab shows the resulting response data that was received.

Follow these steps:

  1. To view the request upon execution, click the Request tab.

    Screenshot of Web Service Execution (XML) Request tab for Tutorial 8

  2. To view the response upon execution, select the Response tab.

    Screenshot of Web Service Execution (XML) Response tab for Tutorial 8

Tutorial 8 - Review

In this tutorial, you: