Generating a Java client proxy and a sample application from a WSDL document using the WebSphere run-time environments
Prerequisites:
- Create a dynamic Web project as described in Creating a WebSphere Server and Web project. It is strongly suggested that you start the server before running the Web service wizard since it may take several minutes to start the WebSphere Application Server depending on the speed of your computer. To start the server, select it in the Servers view (Window > Show View > Servers), right-click and click Start.
- Discover and import a WSDL document into the Web project. You can only use a WSDL file that contains a service element.
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.
To generate a Java client proxy and a sample application from a discovered WSDL document:
- Switch to the J2EE perspective (Window > Open Perspective > J2EE).
- In the Project Explorer view, select the Web project in which you want to generate a sample application.
- Click File > New > Other. Select Web Services in order to display the various Web service wizards. Select the Web Service Client wizard. Click Next.
- Web Services page: Select the type of proxy to be generated, and whether or not it will be tested. Click Next.
- Client Environment Configuration page: Select the run-time environment and the server for your Web service client.
- Click Explore Options and select the IBM WebSphere run-time environment and select the server on which you want to run your Web service client. If you want to use the IBM SOAP run-time environment or the Apache Axis 1.0 run-time environment, refer to the appropriate task.
- Select the type and name of project in which you want the Web service client created.
- If you enter the name of an existing project, the project type field must match that of the existing project. 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.
- If you enter a name of a project that does not already exist, the wizard will create the project for you.
- Select an existing EAR or enter a unique name to associate the Web service client with a different EAR than the Web service EAR. Note: Selecting different EARs for the Web service and Web service client can reduce the chance of encountering run time errors, but will use more system resources.
- Web Service Selection page: Enter the URI to the WSDL, WSIL, or HTML file that will be used to generate the client. You can optionally generate a WSIL file from this file as well. Click Next.
- Web Service Proxy page: This page shows the options for the proxy. It lists the folder where the proxy will be generated, and you can optionally enable security for the proxy, and create custom mappings between namespaces and packages. Click Next.
- Web Service Client Namespace to Package Mappings page: if you selected Define custom mapping for namespace to package on the previous page, you can enter your custom mapping pairs on this page by clicking Add. Alternately, you can click Import to import custom mapping pairs from a .properties file. The content of the properties file must be of the format namespace=package . You can also choose to disable data binding and use SOAP elements when generating Java from WSDL. Click Next.
- Web Service Client Test page: Select the test facility that you will use to test the proxy, and the methods that you want included in the proxy. Note that the Universal Test Client (UTC) is only compatible with Web service clients deployed on WebSphere servers. Click Next.
- Click Finish. If you have selected to test the proxy, the test client will open in a browser window.
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 or the Universal test client.
- If you have selected to test the generated proxy using Web service JSPs, the proxy is launched in a Web browser at the following URL: http://localhost: port/ WebProjectClient/sampleBeanName/WebServiceName/TestClient.jsp You can use this sample application to test the Web service by selecting a method, entering a value for the method, and clicking Invoke. The result of the method will display in the results pane.
- If you have selected to test the generated proxy using the Universal Test Client, it will be launched in a browser window at the following URL: http://localhost:9080/UTC/preload?object= BeanPackage. BeanServiceProxy. In the Reference pane, under Object References, expand the proxy stub to display the methods of the Web service. Click the method you want to test, enter a value in the Parameters pane, and click Invoke. The result will be generated below.
- If you have selected to test the Web service using the Web Services Explorer, the Explorer will open. Select the operation you want to test, enter the required information, and click Go. The result will display in the Status pane.
For more information on creating a Web project, refer to the Web application development documentation.
Related Concepts
Tools for Web services development
Web services development
Web services run-time environments
Related Tasks
Developing Web services
Using the Web Services ExplorerRelated Reference
WSDL documents