Testing a JAX-RPC web service generated by the command line

After you have deployed a web service that you created with a command line tool, you can test it using Web Services Explorer, a web service client wizard, or by importing generated client code to a new Java™ or Web project.

Before you begin

Before testing the web service you have created using the command line tools, you must have deployed the EAR to the server. To do this, follow the instructions outlined in Deploying a web service to a server using the command line tools

Starting the Web server

About this task

Before you test the web service, you must first start the Web server. To start the server:

Procedure

  1. Switch to the Servers view (Window > Show View > Servers).
  2. In the Servers pane, ensure that you are viewing the Servers tab.
  3. From the pop-up menu of the server that you created and configured, select Start.

Results

Now, you can test the web service using one of the following three methods:

Testing a web service using Web Services Explorer

About this task

To test a web service using Web Services Explorer:

Procedure

  1. In the Services view, select the web service or client object.
  2. Right-click the WSDL file and from the pop-up menu, select Test with Web Services Explorer.

Testing a web service using a web service client wizard

About this task

You can use the Web services client wizard to generate a client proxy, and then you can test your web service using the generated JSP code.

To test your web service using a Web service client wizard:

Procedure

  1. In the Services view select the web service object
  2. Right-click and select Generate > Client.
  3. The Service definition field should be pre-filled with the WSDL file. Move the slider to Test Client, and ensure the Server and Web service runtime selections are correct. You can click Finish at this point or make additional configuration selections for the client on the following pages.

Results

Test the web service in the embedded Web browser using the generated JSP.

Testing a web service with client code generated by the web services command line

About this task

To test your web service with the client code generated by the web services command line, you can import the generated code into either a new Java or Web project. Note: The new Web or Java project that you create in this task is separate from the EJB and Web project that you imported with your EAR file when you deployed your web service.

Importing the WSDL2Client generated client Enterprise Application (EJB and Servlet)

Procedure

  1. Switch to the Java EE perspective (Window > Open Perspective > Java EE).
  2. Right-click and select Import > EAR File. Select your target server. Click Next.
  3. Browse to the client EAR file location (usually under ClientProject/client-side) and modify the Project name if desired. Click Finish.
  4. Open the Servers view. If a server already exists, go to step 7.
  5. In the Server Configuration pane, right-click Servers and select New > Server.
  6. Select the desired type of server and enter the Server name. Click Finish.
  7. Right-click on the server for the application, and select Add and remove projects.
  8. Select the newly imported client enterprise application from Available projects, click Add, then click Finish.

Importing the WSDL2Client generated client Enterprise Application (J2EE Application)

Procedure

  1. Switch to the Java EE perspective (Window > Open Perspective > Java EE).
  2. Right-click and select Import > EAR File. Click Next.
  3. Browse to the client EAR file location (usually under ClientProject/client-side) and modify the Project name if desired. Click Finish.
  4. From the tool bar, select Run > Run..., choose from the installed servers or stubs, and then click New.
  5. Select the project from the Enterprise Application combo box and then click Run.

Importing the generated client code into a Java project

Procedure

  1. Switch to the Java perspective ( Window > Open Perspective > Java).
  2. Create a new Java project by selecting File > New > Other. Select Java and Java Project from the lists. Click Next.
  3. Type a name for your new Java project. Click Finish.
  4. In the Package Explorer pane, select Properties from the new Java project's pop-up menu. Select Java build path.
  5. Click the Libraries tab. Click Add Variable.
  6. In the New Variable Classpath Entry dialog, select WAS_version_PLUGINDIR from the list. Click Extend.
  7. In the Variable Extension dialog, expand the lib folder. Select the following five JAR files by holding the CTRL key as you make your selections:
    • commons-discovery.jar
    • commons-logging-api.jar
    • qname.jar
    • webservices.jar
    • wsdl4j.jar
  8. Click OK.
  9. In the Package Explorer pane, select your Java project.
  10. Select File > Import. Select File System from the list. Click Next.
  11. Click Browse. Browse to the command line test directory. Expand the project directory (specified in -project when you ran the web services command line tool).
  12. Expand the Client-side folder. Ensure that all the check boxes beside each folder, excluding META-INF, are selected.
  13. Click Finish.

Importing the generated client code into a Web project

Procedure

  1. Switch to the Java perspective ( Window > Open Perspective > Java).
  2. Create a new Web project by selecting File > New > Other. Select Web and Web Project from the lists.
  3. Type a name for the new client Web project. In the EAR Project field, select the EAR file that you imported from the drop-down menu.
  4. In the EAR Project field, select the EAR file that you imported from the drop-down menu.
  5. Click Finish.
  6. In the Package Explorer pane, select Properties from the client Web project's pop-up menu. Select Java build path.
  7. Click the Libraries tab. Click Add Variable.
  8. In the New Variable Classpath Entry dialog, select WAS_version_PLUGINDIR from the list. Click Extend.
  9. In the Variable Extension dialog, expand the lib folder. Select the following six JAR files by holding the CTRL key as you make your selections:
    • commons-discovery.jar
    • commons-logging-api.jar
    • j2ee.jar
    • qname.jar
    • webservices.jar
    • wsdl4j.jar
  10. Click OK.
  11. In the Package Explorer pane, select the JavaSource folder in the client Web project. Select File > Import.
  12. Select File System from the list. Click Next.
  13. Click Browse. Browse to the command line test directory. Expand the project directory (specified in -project when you ran the web services command line tool).
  14. Expand the Client-side folder. Ensure that all the check boxes beside each folder, excluding META-INF, are selected.
  15. Click Finish.

Results

After you have tested your web service, you can write a client application to access the web service.


Feedback