WebSphere Application Server Version 6.1 Feature Pack for Web Services
             Operating Systems: AIX, HP-UX, i5/OS, Linux, Solaris, Windows, z/OS

             Personalize the table of contents and search results
             New or updated topic for this feature pack

Developing Java artifacts for JAX-WS applications from a WSDL file

JAX-WS tooling enables the generation of Java artifacts that are needed to develop JAX-WS Web services when starting with a WSDL file.

Before you begin

When using a top-down development approach to developing Java API for XML-Based Web Services (JAX-WS) Web services by starting with a Web Services Description Language (WSDL) file, you must obtain the Uniform Resource Locator (URL) of the WSDL file.

[Windows] [z/OS] 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] [i5/OS] 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.

About this task

You can use the JAX-WS tool, wsimport, to process a WSDL file and generate portable Java artifacts that are used to create a Web service. The portable Java artifacts created using the wsimport tool are:

Procedure

Run the wsimport -keep -verbose wsdl_URL command to generate the portable artifacts. The wsimport tool is located in the app_server_root\bin\ directory. Because the -verbose option is specified, a list of all the generated files is displayed when the command runs.

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 the app_server_root\bin\ directory.
    <?xml version="1.0" encoding="UTF-8"?>
    <!--
     * This program may 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:9080/WSSampleSei/PingService" />
    		</wsdl:port>
    	</wsdl:service>
    </wsdl:definitions>
    
  2. Run the wsimport command from the app_server_root\bin\ directory.
    [Windows]
    app_server_root\bin\wsimport -keep -verbose ping.wsdl
    [Linux] [AIX] [HP-UX] [Solaris] Linux and UNIX-based platforms 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,
    app_server_root/bin/wsimport -keep -verbose ping.wsdl 
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 that contains the ping method definition. The PingStringInput.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 that is used by the JAX-WS client.

What to do next

Complete the JavaBeans implementation.



In this information ...


Related concepts

IBM Redbooks, demos, education, and more


Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience.

This feature requires Internet access.

IBM Suggests
Task topic    

Terms of Use | Feedback

Last updated: Nov 25, 2008 2:35:59 AM CST
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.wsfep.multiplatform.doc/info/ae/ae/twbs_jaxwsfromwsdl.html