Example: Developing Web services clients

 

Example: Developing Web services clients

This example takes you through the steps to develop a Web services client. The development process is based on the Web Services for Java 2 Platform,
Enterprise Edition (J2EE) and the Java API for XML-based remote procedure call (JAX-RPC) specification.

You need a Web Services Description Language (WSDL) file to use Web services. Before you begin this task, locate the WSDL file that defines the Web service that you want to access. You can locate the WSDL from the services provider through e-mail, downloading, or through a Uniform Resource Locator (URL).

For a Java application to act as a Web service client, a mapping between the Web Services Description Language (WSDL) file and the Java application must exist. The mapping is defined by the Java API for XML-based RPC (JAX-RPC) specification. You can use a Java component to implement a Web service by specifying the component interface and binding information in the WSDL file and designing the application server infrastructure to accept the service request. This entire process is based on the Web Services for J2EE specification. The JAX-RPC specification defines the mapping between a WSDL file, Java code and XML Schema types.

Create the client code and artifacts that enable the application client to access a Web service by following the steps provided.

Steps for this task

  1. Obtain the Web Services Description Language (WSDL) document for the Web service that you want to access.

    You can locate the WSDL from the services provider through e-mail, through a Uniform Resource Locator (URL) or by looking it up in a Universal Description, Discovery and Integration (UDDI) registry.

  2. Develop client bindings from your WSDL file.

    The WSDL2Java command-line tool is run against your WSDL file to develop client bindings.

    The information needed to invoke the Web service is generated, including the service endpoint interface and implementations, the generated service interface and the ibm-webservicesclient-bnd.xmi and ibm-webservicesclient-ext.xmi deployment descriptors.

  3. Implement the client.

    See Chapter 4 of the JSR-109 specification. You can access the specification through Web services: Resources for learning.

    Note: If an application creates a number of threads in the JSR-109 client, the meta data (including the WebSphere Application Server configuration) is not copied to the thread, and the Global Security Handler is not called.

    You can also review the GetQuote client in the WebServicesSamples application available in the Samples Gallery.

  4. Assemble the module.

    Assemble the client JAR file into an EAR file or assemble the client WAR file into an EAR file.

  5. Configure the deployment descriptors.

    Configure the client deployment descriptor.

    Configure the ibm-webservicesclient-bnd.xmi deployment descriptor.

  6. Test the Web services client.

    You should test the client to make sure it correctly operates and binds to the Web service.




Searchable topic ID: rwbs_devxmpclient