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 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

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

  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.

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

Testing a Web service using Web Services Explorer

To test a Web service using Web Services Explorer:

  1. Switch to the Web perspective ( Window > Open Perspective > Web).
  2. In the Project Navigator pane, locate your WSDL file by doing one of the following:
    • If your EAR file contains Java beans, expand WebContent > WEB-INF > wsdl of the imported Web project. 
    • If your EAR file contains EJB beans, expand EJBModule > META-INF > wsdl of the imported EJB project.
  3. Right-click the WSDL file and from the pop-up menu, select Web Services > Test with Web Services Explorer.

Testing a Web service using a Web service client wizard

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:

  1. Switch to the Web perspective ( Window > Open Perspective > Web).
  2. In the Project Navigator pane, locate your WSDL file by doing one of the following:
    • If your EAR file contains Java beans, expand WebContent > WEB-INF > wsdl of the imported Web project.
    • If your EAR file contains EJB beans, expand EJBModule > META-INF > wsdl of the imported EJB project.
  3. Select the WSDL file that you want to test.
  4. Select File > New > Other. From the lists, select Web Services and Web Service Client.  Click Next.
  5. Make sure that the Client Proxy type is Java Proxy and that the Test the Web service box is checked.  Click Next.
  6. The WSDL file should be prefilled. If not, browse to it. Click Next.
  7. In the Client Environment Configuration page, ensure that the server that you created and configured (when you deployed your Web service) is listed under Server.  Otherwise, select Edit and then select the server you created under the Existing Servers folder.
  8. Select the Client project type. In the Client Project field, type a unique project name for this client Web project to generate the Web service client code into another client Web project.  Note: Do not accept the default name that appears in this field because it is the name of the imported Web or EJB project. Seletc the EAR for the client project.
  9. Click Finish
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

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)

  1. Switch to the J2EE perspective (Window > Open Perspective > J2EE).
  2. Import the EAR file by right-clicking on J2EE Hierarchy 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. Switch to Server perspective (Window > Open Perspective > Server). If a server already exists, go to step 7.
  5. In the Server Configuration pane, right-click Servers and select New > Server and Server Configuration.
  6. Select the desired type of server (the default is Test Environment under WebSphere® version 5.1) and enter the Server name. Click Finish.
  7. In the Server Configuration pane, open up the Servers tree and right-click on the destination server for the application, 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)

  1. Switch to the J2EE perspective (Window > Open Perspective > J2EE).
  2. Import the EAR file by right-clicking on J2EE Hierarchy 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 either WebSphere v5.1 Application Client or WebSphere v5 Application Client (provided you have installed the server at install time), 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

  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_50_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

  1. Switch to the Java perspective ( Window > Open Perspective > Java).
  2. Create a new Web project by selecting File > New > Other.  Select Web and Dynamic Web Project from the lists.
  3. Type a name for the new client Web project. Ensure that the Configure Advanced Options box is checked.  Click Next.
  4. In the EAR Project field, select the EAR file that you imported from the drop-down menu.
    • If server targeting is enabled (Windows > Preferences > J2EE > Select Enable server targeting support), this page will also contain the option to select the target server by selecting WebSphere Application Server v5.1. Steps 6 through 11 can be omitted. Click Finish and go to step 12.
  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_50_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.

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


Feedback