WAS v8.5 > Develop applications > Develop web services > Develop JAX-WS web services with WSDL files (top-down)

Generate Java artifacts for JAX-WS applications when starting from a WSDL file

First obtain the URL of the WSDL file.

For Windows, if the WSDL file is a local file, the URL looks like...

For UNIX, if the WSDL file is a local file, the URL looks like:

We can specify local files using the absolute or relative file system paths.

Use wsimport to process a WSDL file, and generate the artifacts used to create a web service....

To run...

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

Similar tooling is provided by the Java SE Development Kit (JDK) 6. In general, the artifacts generated by the JDK tools are portable across other compliant runtime environments. However, it is a best practice to use the tools provided with this product to achieve seamless integration within the WAS environment and to take advantage of the features that may be only supported in WAS.

We can invoke wsimport from within the Ant build environments using the Ant task...

(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

You have the required Java artifacts to create a JAX-WS web service. 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 WSDL file to a temporary directory.
    <?xml version="1.0" encoding="UTF-8"?> <!--
    <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:9080/WSSampleSei/PingService" />
       </wsdl:port>
      </wsdl:service> </wsdl:definitions>
  2. Run the wsimport command from the app_server_root\bin\ directory.

    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_server_root>/bin directory. Run the wsimport command,

After generating the template files using 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\PingStringInput.java
com\ibm\was\wssample\sei\ping\PingService.java

The ObjectFactory.java file contains factory methods for each Java content interface and Java element interface generated in the associated ping package. The package-info.java file takes the targetNamespace value and creates the directory structure. The PingServicePortType.java file is the generated service endpoint interface (SEI) class containing the ping method definition. The PinStringInput.java file contains the JAXB generated type values which are Java classes mapped from XML schema types. The PingService.java file is the generated service provider class file used by the JAX-WS client.

Complete the implementation of the web service application by completing the JavaBeans or enterprise beans implementation.


Subtopics


Related concepts:

Development and assembly tools
JAX-WS


Related


Implement web services applications from existing WSDL files with JAX-WS
Completing the JavaBeans implementation for JAX-WS applications
Completing the EJB implementation for JAX-WS applications


+

Search Tips   |   Advanced Search