Previous Next vertical dots separating previous/next from contents/index/pdf

Step 4: Test the Web Service

In this section, you will define and start a server and then use the server's built-in test functionality to test the web service you created in the preceding sections.

Workshop for WebLogic creates a server as part of installation and you will use this local server for testing the application you will create through this tutorial. You must set up the server before you can test any applications.

To Create the Server

  1. In the J2EE perspective, the following views should be visible as tabs at the bottom (by default) of the IDE: Problems, Tasks, Properties, Servers, Database Explorer, Snippets.
  2. Click the Servers view tab, right-click in its window, then click New > Server.

  3. In the New Server dialog, under Select the server type, confirm that BEA Systems > BEA WebLogic Server v10.0 is selected, then click Next.
  4. In the Domain home box, ensure that the dropdown shows the domain directory as the following, where <BEA_HOME> is the location of your BEA installation:
  5. <BEA_HOME>/wlserver_10.0/samples/domains/workshop

  6. Click Finish.

To Assign the Server to the EAR Project

Now you'll associate the server you just created with the EAR project. The EAR project, which contains your web service project, will be deployed to it.

  1. In the Package Explorer, right-click ServicesWebEAR, then click Properties.
  2. In the Properties dialog, in the left pane, select Server. In the right pane, in the Default server box, select BEA WebLogic Server v10.0.
  3. Click OK.

To Start the Server

Note: If you are working through this tutorial for a second time, you must remove previous, duplicate projects (modules) from the server

To Test a Web Service

A web service does not do anything unless a request is received from a client. For testing your web service, Workshop for WebLogic provides a test client through which you can send messages to the service and review the response message. The test client runs in the IDE as an editor window.

To test the web service:

  1. In the Package Explorer view, expand the services package.
  2. Right-click MailingListService.java and select Run As > Run On Server.
  3. In the Run On Server dialog, select the Set server as project default check box. This will reduce the number of steps in the next part of this tutorial, as the IDE will remember your server choice.
  4. Click Finish.
  5. After the server starts and the application is deployed (note the status bar in the lower right corner of the IDE), the IDE displays the test client as shown here:
  6. Test Client

    This web service has only one operation (getCustomers). If there were input values required by getCustomers, there would be input fields that would allow you to specify values. Clicking the getCustomers button sends a request message to the web service.

  7. Click the getCustomers button now to invoke the getCustomers method.

    The test client displays the results of invoking the web service operation (including the returned value) and also the detail of the SOAP-encoded request that was sent to the web service and the response that was received, including the string returned by the getCustomers operation/method: "John Smith".

    Test client results

  8. You can test your web service operation again by clicking Show Operations at the top left corner. You can also examine the automatically generated WSDL (Web Service Description Language) file by clicking the link at the top of the Test Client page.

Click the arrow to navigate through the tutorial:

 

Skip navigation bar   Back to Top