Name
wsdl2java — generates JAX-WS compliant Java code from a WSDL document
Synopsis
wsdl2java
[[-?] | [-help] | [-h]] [-fe frontend
...] [-db databinding
...] [-wv wsdlVersion
...] [-p [wsdlNamespace
=]PackageName
...] [-b bindingName
... ] [-sn serviceName
] [-d output-directory
] [-catalog catalogName
] [-compile] [-classdir compile-class-dir
] [-client] [-server] [-impl] [-all] [-ant] [-keep] [-defaultValues[=DefaultValueProvider
]] [-nexclude schema-namespace
[=java-packagename
]...] [-exsh { true | false }] [-dns { true | false }] [-dex { true | false }] [-wsdlLocation wsdlLocation
] [-xjcargs
] [-noAddressBinding] [-validate] [-v] [[-verbose] | [-quiet]] wsdlfile
Description
wsdl2java takes a WSDL document and generates fully annotated Java code from which to implement a
service. The WSDL document must have a valid portType
element, but it does not need to contain a
binding
element or a service
element. Using the optional arguments you can
customize the generated code. In addition, wsdl2java can generate an Ant based makefile to build your
application.
Arguments
The arguments used to manage the code generation process are reviewed in the following table.
Option | Interpretation |
---|---|
-? | Displays the online help for this utility. |
-help | |
-h | |
-fe | Specifies the front end used by the code generator. The default is jaxws .[a] |
-db | Specifies the data binding used by the code generator. The default is jaxb .[b] |
-wv | Specifies the WSDL version expected by the tool. The default is 1.1 .[c] |
-p [wsdlNamespace =]PackageName | Specifies zero, or more, package names to use for the generated code. Optionally specifies the WSDL namespace to package name mapping. |
-b | Specifies zero, or more, JAXWS or JAXB binding files. Use spaces to separate multiple entries. |
-sn | Specifies the name of the WSDL service for which code is to be generated. The default is to generate code for every service in the WSDL document. |
-d | Specifies the directory into which the generated code files are written. |
-catalog | Specifies the URL of an XML catalog to use for resolving imported schemas and WSDL documents. |
-compile | Compiles generated Java files. |
-classdir | Specifies the directory into which the compiled class files are written. |
-client | Generates starting point code for a client mainline. |
-server | Generates starting point code for a server mainline. |
-impl | Generates starting point code for an implementation object. |
-all | Generates all starting point code: types, service proxy, service interface, server mainline, client mainline, implementation object, and an Ant build.xml file. |
-ant | Generates the Ant build.xml file. |
-keep | Instructs the tool to not overwrite any existing files. |
-defaultValues [=DefaultValueProvider ] | Instructs the tool to generate default values for the generated client and the generated implementation. Optionally, you can also supply the name of the class used to generate the default values. By default, the RandomValueProvider class is used. |
-nexclude schema-namespace [=java-packagename ] | Ignore the specified WSDL schema namespace when generating code. This option may be specified multiple times. Also, optionally specifies the Java package name used by types described in the excluded namespace(s). |
-exsh (true /false ) | Enables or disables processing of extended soap header message binding. Default is false . |
-dns (true /false ) | Enables or disables the loading of the default namespace package name mapping. Default is true . |
-dex (true /false ) | Enables or disables the loading of the default excludes namespace mapping. Default is true . |
-wsdlLocation | Specifies the value of the @WebService annotation's wsdlLocation property. |
-xjc | Specifies a comma separated list of arguments to be passed to directly to the XJC when the JAXB data binding is being used. To get a list of all possible XJC arguments use the -xjc-X . |
-noAddressBinding | Instructs the tool to use the Fuse Services Framework proprietary WS-Addressing type instead of the JAX-WS 2.1 compliant mapping. |
-validate | Instructs the tool to validate the WSDL document before attempting to generate any code. |
-v | Displays the version number for the tool. |
-verbose | Displays comments during the code generation process. |
-quiet | Suppresses comments during the code generation process. |
wsdlfile | The path and name of the WSDL file to use in generating the code. |
[a] Currently, Fuse Services Framework only provides the JAX-WS front end for the code generator. [b] Currently, Fuse Services Framework only provides the JAXB data binding for the code generator. [c] Currently, Fuse Services Framework only provides WSDL 1.1 support for the code generator. |
Using Ant
To call the WSDL to Java code generator from Ant set the java task's classname property to org.apache.cxf.tools.wsdlto.WSDLToJava
.
Example 1 shows the java task to execute this command.
Example 1. Generating a Java code from Ant
<java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true"> <arg value="-client"/> ... <arg value="MyWSDL.wsdl"/> <classpath> <path refid="fsf.classpath"/> </classpath> </java>