Generating a web service client from a WSDL document using the IBM® WebSphere JAX-WS runtime environment

The web service client wizard assists you in generating a Java™ bean proxy and a sample application. The sample Web application demonstrates how to code a proxy file.

Before you begin

Prerequisites:
Restriction: If the you want to run a simple Java web service client outside of any J2EE container, you must generate the web service client into a simple Java project. The web service wizard cannot create a simple Java project. The closest form is an utility project, however running a simple Java web service client (containerless) from an utility project is not supported. You must create a simple Java project before running the web service client wizard. The JDK Compiler compliance level for the simple Java project must be set to the Java version on which the WebSphere Application Server runs.

About this task

To generate a Java client proxy and a sample application from a discovered WSDL document:

Procedure

  1. Switch to the Java EE perspective (Window > Open Perspective > Java EE).
  2. Click File > New > Other. Select Web Services in order to display the various web service wizards. Select the Web Service Client wizard. Click Next.
  3. Web Services page: select the WSDL file that you will use to generate the client. You can optionally choose to do the following:
    1. Select the stages of web service client development that you want to complete using the slider. This will set several default values on the remaining wizard panels.
      • Develop: this will develop the WSDL definition and implementation of the web service client. This includes such tasks as creating the modules which will contain the generated code, WSDL files, deployment descriptors, and Java files when appropriate.
      • Assemble: this ensures the project that will host the web service client gets associated to an EAR when required by the target application server.
      • Deploy: this will create the deployment code for the client.
      • Install: this will install and configure the Web module and EARs on the target server. If any changes to the endpoints of the WSDL file are required they will be made in this stage.
      • Start: this will start the server once the client has been installed on it.
      • Test: this will provide various options for testing the service, such as using the Web Service Explorer or sample JSPs.
    2. Select your server: the default server is displayed. If you want to deploy your service to a different server click the link to specify a different server.
      This task supports the following server runtime environments:
      • WebSphere Application Server V7.0 or later
      • WebSphere Application Server Liberty Profile V8.5.5
    3. Select your runtime: the default runtime is displayed. If you want to deploy your service to a different runtime click the link to specify a different runtime.
    4. Select the client project: the project selected in your workspace is displayed. To select a different project and EAR click on the project link. You can select a web project, an EJB project, a Java project, or a Java EE application client project as the location for the client code. Ensure that the project selected as the Client Web Project is different from the Service Web Project, or the service will be overwritten by the client's generated artifacts. For JAX-WS web services, the server and client projects can share the same EAR.
    5. Monitor the web service: this will send the web service traffic through the TCP/IP Monitor, which allows you to watch the SOAP traffic generated by the web service and to test this traffic for WS-I compliance. Alternately you can manually set up a TCP/IP monitor as described in Using the TCP/IP Monitor to test web services. Note that if you are routing web service traffic through the TCP/IP monitor that you cannot test the web service using the Universal Test Client.
  4. WebSphere JAX-WS Web Service Client Configuration page:
    • Output folder: Select the folder where you want the client's Java classes to be generated or accept the default.
    • Target package: The web services client wizard generates a number of Java files from the specified WSDL. By default it will create a package name based on the namespace specified in the WSDL file. To override this default behavior you can specify your own package name for the namespace in the WSDL file.
    • Generate portable client: Selecting this checkbox would allow you to move your web service client code from one machine to another or from one instance of WebSphere Application Server to another. If this option is selected, the WSDL document and all the XML Schema and other WSDL documents that it depends upon will be copied into the client project under WEB-INF/wsdl and a file:relativeURL pointing to this copy will then be injected into the JAX-WS Service class's static initialization block.
    • Enable asynchronous invocation for generated client: If you select to enable an asynchronous client, for each method in the web service two additional methods will be created. These are polling and callback methods which allow the client to function asynchronously.
    • Specify JAX-WS or JAXB binding files: If you have created JAX-WS or JAXB custom binding files, select this check box to use them to create this web service.
    • Customize client proxy class name: You can accept the default proxy name or enter your own.
    • Generate web service deployment descriptor: For JAX-WS web services deployment information is generated dynamically by the runtime; static deployment descriptors are no longer required. Selecting this checkbox will generate them.
    • Allow vendor extensions: If you select this check box, the -extension option is added to the wsgen or wsimport command. The -extension option specifies whether to enable or accept custom extensions for functionality not specified by the JAX-WS specification. Use of the extensions can result in applications that are not portable or do not interoperate with other implementations. For details, see wsgen command for JAX-WS applications and wsimport command for JAX-WS applications topics available in the Information Center for WebSphere Application Server.
  5. Custom binding declaration page: If you selected to supply a JAX-WS or JAXB binding file on the previous page, you can browse to where they are located.
  6. Proxy generation configuration page: If you selected to customize the client proxy class name, use this page to specify a proxy class name for each port.
  7. Web Service Client Test page:
    • Test the generated proxy: If selected, the sample client will be launched in a Web browser enabling you to test the functionality.
    • Select your test facility. You can test the generated proxy in the Universal Test Client or the Web Service Explorer, or you can generate sample JAX-WS 2.0 JSPs. Note that if you are routing web service traffic through the TCP/IP monitor that you cannot test the web service using the Universal Test Client.
    • Folder: If you selected to test the proxy through a JSP, you can select the folder where the JSP will be located, and you can select the methods that will be included in the JSP.
    • Methods: Select the methods to expose. If you selected to enable asynchronous invocation, the asynchronous methods should be listed as well.
    • Run test on server: this will start the server for you automatically.
  8. Click Finish. If you have selected to test the proxy, the test client will open in a browser window.

Results

The generated Java bean proxy provides a remote procedure call interface to the web service. The sample Web application demonstrates how to code the proxy file.

Once you have generated your Java client proxy, you may test the methods of the web service through the proxy using web services sample JSPs, the Universal test client, or the Web Services Explorer.


Feedback