+

Search Tips   |   Advanced Search

Develop a JAX-WS client from a WSDL file


JAX-WS tooling supports generating Java artifacts we need to develop static JAX-WS Web services clients when starting with a Web Services Description Language (WSDL) file.

When you use a top-down development approach to developing JAX-WS Web services by starting with a WSDL file, obtain the Uniform Resource Locator (URL) for the WSDL file.

(Windows) If the WSDL file is a local file, the URL looks like this example: file:drive:\path\file_name.wsdl.

[Linux] [AIX] [HP-UX] [Solaris]

If the WSDL file is a local file, the URL looks like this example: file:/path/file_name.wsdl.

You can also specify local files using the absolute or relative file system path.

The static client model for JAX-WS is the called the dynamic proxy client. The dynamic proxy client invokes a Web service based on a service endpoint interface that is provided. After you create the proxy, the client application can invoke methods on the proxy just like a standard implementation of those interfaces. For JAX-WS Web service clients using the dynamic proxy model, use the JAX-WS tool, wsimport, to process a WSDL file and generate portable Java artifacts that are used to create a Web service client. Create the following portable Java artifacts using the wsimport tool:

Supported configurations: The wsimport, wsgen, schemagen and xjc command-line tools are not supported on the z/OS platform. This functionality is provided by the assembly tools provided with WAS running on the z/OS platform. Read about these command-line tools for JAX-WS applications to learn more about these tools.

Best practice: WebSphere provides JAX-WS and JAXB tooling. The wsimport, wsgen, schemagen and xjc command-line tools are located in...

APP_ROOT\bin\

Similar tooling is provided by the Java SE Development Kit (JDK) 6. For the most part, artifacts generated by both the tooling provided with WebSphere and the JDK are the same. In general, artifacts generated by the JDK tools are portable across compliant runtime environments. However, it is a best practice to use the WebSphere tools to achieve seamless integration within the WebSphere environment. bprac

  Run the wsimport command to generate the portable client artifacts.

The wsimport tool is located in the APP_ROOT\bin\ directory.

(Windows)

APP_ROOT\bin\wsimport.bat wsdl_URL 

[AIX] [HP-UX] [Linux] [Solaris]

APP_ROOT/bin/wsimport.sh wsdl_URL
(Optional) Use the following options with the wsimport command:

Read about the wsimport command to learn more about this command and additional options that we can specify.

 

Results

we have the generated Java artifacts to create a JAX-WS client that can invoke JAX-WS Web services. To learn more about the usage, syntax, and parameters for the wsimport command, see the wsimport command for JAX-WS applications documentation.

 

Example

The following example illustrates how the wsimport command is used to process the sample ping.wsdl file to generate portable artifacts.

  1. Copy the following ping.wsdl file to a temporary directory.

    <?xml version="1.0" encoding="UTF-8"?>
    <!--
     * This program can be used, run, copied, modified and distributed
     * without royalty for the purpose of developing, using, marketing, or distributing.
     -->
    <wsdl:definitions 
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
      
        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
      
        xmlns:tns="http://com/ibm/was/wssample/sei/ping/"
      
        xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="PingService"
      targetNamespace="http://com/ibm/was/wssample/sei/ping/">
      <wsdl:types>
        <xsd:schema
          targetNamespace="http://com/ibm/was/wssample/sei/ping/"
          
        xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    
    
          <xsd:element name="pingStringInput">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="pingInput" type="xsd:string" />
              </xsd:sequence>
            </xsd:complexType>
          </xsd:element>
        </xsd:schema>
      </wsdl:types>
      <wsdl:message name="pingOperationRequest">
        <wsdl:part element="tns:pingStringInput" name="parameter" />
      </wsdl:message>
      <wsdl:portType name="PingServicePortType">
        <wsdl:operation name="pingOperation">
          <wsdl:input message="tns:pingOperationRequest" />
    
        </wsdl:operation>
      </wsdl:portType>
      <wsdl:binding name="PingSOAP" type="tns:PingServicePortType">
        <soap:binding style="document"
          transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="pingOperation">
          <soap:operation soapAction="pingOperation" style="document" />
          <wsdl:input>
            <soap:body use="literal" />
          </wsdl:input>
        </wsdl:operation>
      </wsdl:binding>
      <wsdl:service name="PingService">
        <wsdl:port binding="tns:PingSOAP" name="PingServicePort">
          <soap:address
            location="http://localhost:9082/WSSampleSei/PingService" />
        </wsdl:port>
      </wsdl:service>
    </wsdl:definitions>
    
    

  2. Run the wsimport command from the APP_ROOT\bin\ directory.

    (Windows)

    APP_ROOT\bin\wsimport.bat -keep -verbose ping.wsdl
    

    [Linux] [AIX] [HP-UX] [Solaris]

    Operating systems such as AIX or Linux source the script to the parent shell to inherit the exported variables by running the following command:

    . ./setupCmdLine.sh  (Notice the space between the periods.)
    
    from the . /APP_ROOT>/bin directory. Run the following wsimport command:

    APP_ROOT/bin/wsimport.sh -keep -verbose ping.wsdl 
    
After generating the template files from the wsimport command, the following files are generated:

com\ibm\was\wssample\sei\ping\ObjectFactory.java com\ibm\was\wssample\sei\ping\package-info.java com\ibm\was\wssample\sei\ping\PingServicePortType.java com\ibm\was\wssample\sei\ping\PingService.java com\ibm\was\wssample\sei\ping\PingStringInput.java

The ObjectFactory.java, PingService.java and PingServicePortType.java files are the generated Java class files to use when you package the Java artifacts with the client implementation inside a JAR or a WAR file.

 

Next steps

Complete the client implementation.


JAX-WS
JAX-WS client model
Assembly tools

 

Related tasks


Implementing JAX-WS Web services clients
Invoking JAX-WS Web services asynchronously
Develop a dynamic client using JAX-WS APIs
Generating Java artifacts for JAX-WS applications from a WSDL file

 

Related


wsimport command for JAX-WS applications
Web services specifications and APIs

 

Related information


Java API for XML Web Services (JAX-WS) API documentation
Java API for XML Web Services (JAX-WS) API User's Guide documentation