wsdl2Java

Description

Generates Java code for client side artifacts from the WSDL, where WSDL URI is the URI (universal resource identifier) of the WSDL file.

wsdl2java generates a service implementation template file with a .java.new extension. Remove the .new extension and enter your business logic into the implementation file before deploying it as a Web service.

NoteWhen you expose a component that uses EAServer-specific holder types as a Web service, the convention for generating the client-side holders classes is that they are always generated under a package.holders.type hierarchy. For example, when you expose a component as a Web service that uses BCD.MoneyHolder, the conversion on the client-side results in a JAX-RPC specific holder contained under BCD.holders.MoneyHolder. You will not use EAServer-specific types on the Web service client side.

Syntax

Command line:

wsdl2java 
[-classpath path ] 
[-compile true | false ] 
[-factory class_name ] 
[-fileNS2pkg file_name ] 
[-genAll true | false  ] 
[-genHelper true | false ] 
[-genImplTemplate true | false ] 
[-genRefrencedOnly true | false ] 
[-genSkeleton true | false ] 
[-genStub true | false ] 
[-gentestCase true | false ] 
[-gentypes true | false ] 
[-genWSDD true | false ] 
[-handlerFile fileName ] 
[-noImport true | false ] 
[-noWrapped true | false ] 
[-ns2pkg  package=namespace ] 
[-outputDir path] 
[-package packageName ] 
[-passwd password] 
[-scope Request | Application | Session ] 
[-serverside true | false] 
[-timeout seconds ] 
[-tm argument ] 
[-typeMappingVer 1.1 | 1.2 ] 
[-user userName ] 
WSDLURI

Ant build file:

<taskdef name="wst_antTask" classname="com.sybase.wst.wstool.ant.AntTask"/>
<target name="wsdl2java" > <wst_antTask command="wsdl2java" 
[classpath=“path”] 
[compile=“true | false ] 
[factory=“class_name”] 
[fileNS2pkg=“file_name”] 
[genAll=“true | false ] 
[genHelper=“true | false”] 
[genImplTemplate=“true | false] 
[genRefrencedOnly=“true | false] 
[genSkeleton=“true | false”] 
[genStub=“true | false] 
[gentestCase=“true | false] 
[gentypes=“true | false”] 
[genWSDD=“true | false] 
[handlerFile=“fileName] 
[noImport=“true | false ] 
[noWrapped=“true | false”] 
[ns2pkg=“package=namespace”] 
[outputDir=“path”] 
[package=“packageName”] 
[passwd=“password”] 
[scope=“Request | Application | Session”] 
[serverside=“true | false”] 
[timeout=“seconds”] 
[tm=“argument”] 
[typeMappingVer=“1.1 | 1.2”] 
[user=“userName”] 
WSDLURI=“resourceIdentifier” >

Where:

Option

Description

classpath

Specify the classpath in quotes.

compile

If true, compiles the generated source code.

factory

Name of the class file that implements the GenerateFactory class.

fileNS2pkg

The name of the file that contains the ns2pkg (namespace to package) mappings. Use this option instead of the ns2pkg options to declare multiple mappings. For example, the Ns2pkg.properties file contains two mappings:

http\://Host:Port/Man.xsd=com.sybase.manf
http\:/Host:Port/Purch.xsd=com.sybase.Purchase

and can be used as follows:

wstool wsdl2java -fileNs2pkg Ns2pkg.properties myTest.wsdl

genWSDD

If true, generates a Deploy.wsdd file.

genImplTemplate

If true, generates a template for the implementation code.

genStub

If true, generates the stub files.

genAll

If true, generates and compiles the stubs, wsdd, and ImplTemplate files. If set to true, this option overrides the settings of genWSDD, genImplTemplate, and genStub.

NoteWhen user defined types that are not Java beans are used, the generated test client is not compilable as wsdl2java cannot construct the type in the test code.

gentestCase

If true, generates a test case.

gentypes

Set this option to false when you start with java2wsdl, or you will overwrite existing types. Default is true.

genHelper

If true, generates helper classes for metadata.

genSkeleton

If true, generates the skeleton files.

handlerFile

The handler class file that contains any special routines (handlers) for this Web service.

noImports

If true, generates code for the current WSDL only.

noWrapped

If true, turns off support for “wrapped” document/literal. Wrapped is a document literal variation, that wraps parameters as children of the root element.

ns2pkg

The namespace to package value pair, in the form namespace=package. You can only declare one namespace to package pair using this option. Use the fileNS2pkg option to declare multiple mappings.

outDir

The output directory for the generated files.

package

The package name to be used for namespace to package mappings.

passwd

The password required by the user to access the WSDL URI.

scope

The scope of the deploy.wsdd: request, application, or session.

serverside

If true, generates the server-side bindings for the Web service.

timeout

In seconds, the amount of time allowed for this command to complete before timing out.

tm

specify the type mapping file name, if any custom data types are being used. For example, the type mapping file myTMfile.map has the following contents:

t1.QName = nonbeansample:Book 
t1.Serializer =  nonbeansample.BookSerializer
t1.Deserializer =  nonbeansample.BookDeserializer
t1.SerializerFactory =  nonbeansample.BookSerFactory 
t1.DeserializerFactory =   nonbeansample.BookDeserFactory 
t1.TypeName =  nonbeansample.Book 
t1.EncodingType = http://schemas.xmlsoap.org/soap/encoding/ 
# Specify the webservice if the type 
# mappings are on the server 
t1.ServiceName = myCollection/myService

typeMappingVer

Type mapping version to use. The default is 1.1. Acceptable values are 1.1 and 1.2.

user

The user name used to access the WSDL URI.

Examples

Example 1

This example uses CodeGetTest.wsdl as the input WSDL file and generates the Java output file to the out directory:

wstool  wsdl2java -genTestCase false -genHelper true -genImplTemplate true -genRefrencedOnly false -genSkeleton true -genStub true -genWSDD true -tm tmfile.map -classpath "d:\out;d:\wstool\test\tm\classes" -genall false -outDir out CodeGenTest.wsdl

Ant build example:

<wst_antTask command="wsdl2java" entity="d:\wstool\test\sample.wsdl" />