The Java2WSDL tool maps a Java™ class
to a WSDL document.
The Java2WSDL tool accepts a Java class
as input and produces a WSDL file representing this class as output.
If a file exists at the output location, it is overwritten.
The
WSDL document generated by Java2WSDL contains WSDL and XML schema
constructs that are automatically derived from the input class. Command-line
arguments permit overriding of many of these default values.
Syntax
The Java2WSDL tool is located in
the <WS-install-dir>\appserver\bin directory.
Java2WSDL
[<arguments>] <class>
Arguments
Mandatory argument:
<class>
- The fully-qualified name (including package name) of
one of the following Java classes:
- A stateless session EJB remote interface (extends javax.ejb.EJBObject)
- A Service Endpoint Interface (extends java.rmi.Remote)
- A Java bean
The Java2WSDL tool locates the class
in CLASSPATH.
Optional arguments:
- -help
- Displays the help message.
- -output <WSDLfile>
- Indicates the path and file name of the output WSDL file. If not
specified, the default WSDL file, <class>.wsdl, is written into
the current directory.
- Data type
- String.
- Units
- Not applicable.
- Default
- <class>.wsdl in the current directory.
- Range
- Legal file names for your system.
- -location <location>
- Provides the location (URL) of the service. Normally this value
is filled in automatically when the web service is deployed. To generate
WSDL files containing a location URL without deploying, use this argument
to specify the location. If no location is specified, a warning is
displayed to remind you that the generated WSDL file should not be
published, because the final location has not yet been determined.
The name after the last slash or backslash is the name of the service
port (unless overridden by the -servicePortName argument).
The service port address location attribute is assigned the specified
value.
- Data type
- String.
- Units
- Not applicable.
- Default
- file:undefined_location.
- Range
- Legal URL strings.
- -portTypeName <name>
- Indicates the name to use for the portType element. If not specified,
the <class> name is used.
- Data type
- String.
- Units
- Not applicable.
- Default
- <class>.
- Range
- Not applicable.
- -bindingName
- Indicates the name to use for the binding element. If not specified,
the binding name is the service element name ( -serviceElementName argument)
appended with "SOAPBinding".
- Data type
- String.
- Units
- Not applicable.
- Default
- <serviceElementName> <SOAPBinding>.
- Range
- Not applicable.
- -serviceElementName <name>
- Indicates the name of the service element.
- Data type
- String.
- Units
- Not applicable.
- Default
- <portTypeName> Service, where <portTypeName>
is the name specified with the -portTypeName argument
or the default portTypeName.
- Range
- Not applicable.
- -servicePortName <name>
- Indicates the name of the service. If not specified, the service
name is derived from the -location argument.
- Data type
- String.
- Units
- Not applicable.
- Default
- The name after the last backslash '\' of the -location argument
or the <class> name.
- Range
- Not applicable.
- -namespace <targetNamespace>
- Indicates the target namespace for the WSDL document being generated.
- Data type
- String.
- Units
- Not applicable.
- Default
- Package name of <class> mapped to a namespace.
- Range
- Not applicable.
- -PkgtoNS <package> <namespace>
- Indicates the mapping of a Java package
to a namespace. If a package is found that does not have a namespace,
Java2WSDL will generate a suitable namespace name. This argument can
be repeated to specify mappings for multiple packages.
- Package:
- Data type
- String.
- Units
- Not applicable.
- Default
- Not applicable.
- Range
- Java package names.
- Namespace:
- Data type
- String.
- Units
- Not applicable.
- Default
- Not applicable.
- Range
- Not applicable.
- -methods <method> [,<method>...]
- If this argument is specified, only the indicated methods in your
class are exported into the WSDL file. The list of methods must be
separated by commas. If not specified, all methods defined by the
class are exported into the WSDL file.
- Data type
- Comma-separated list of strings.
- Units
- Not applicable.
- Default
- All methods defined by <class>.
- Range
- Methods defined by <class> or its parent classes.
The -all argument is another
way of selecting methods to include.
- -all
- If this argument is specified, Java2WSDL looks into parent classes
to determine the list of methods to export into the WSDL file. The
-methods argument is not used if -all is
specified. The -stopClasses argument specifies
when to terminate the upward scan for methods.
- -implClass <impl-class>
- The Java2WSDL tool uses method parameter names to construct the
WSDL message part names. The message names are obtained from the debug
information in <class>. If this class was compiled without debug
information or if it is an interface, the method parameter names are
not available. In this case, use the -implClass argument
to provide an alternative class from which to obtain method parameter
names. The <impl-class> does not have to
implement <class> if <class> is an interface, but it must implement
the same methods as <class>.
- Data type
- String.
- Units
- Not applicable.
- Default
- Not applicable.
- Range
- Java classes in CLASSPATH that
implement the same methods as <class>.
- -stopClasses <parent> [,<parent>...]
- Java2WSDL searches inherited classes and interfaces to construct
the list of methods for WSDL operations (if the -all argument
is specified). Java2WSDL searches inherited
classes and interfaces when generating extended complexTypes. The
search stops whenever a class or interface is found that is within
a package that begins with Java or
Javax. You can also use the -stopClasses argument
to define additional classes that will cause the search to stop.
- Data type
- List of strings separated by commas.
- Units
- Not applicable.
- Default
- The default stopClasses are java.* and javax.*
- Range
- Parent classes of <class>.
- -style RPC | DOCUMENT | WRAPPED
- Specifies the WSDL style to be used in the generated WSDL. This
argument is used with the -use argument.
- If you specify RPC with -use
ENCODED, or omit -use, a style=rpc/use=encoded WSDL
is generated.
- If you specify RPC with -use
LITERAL, a style=rpc/use=literal WSDL
is generated.
- If you specify DOCUMENT with - use
LITERAL or omit -use, a style=document/use=literal WSDL
is generated.
- If you specify WRAPPED with -use
LITERAL or omit -use, a style=document/use=literal WSDL
with a "wrapped" format is generated.
- If you specify DOCUMENT unwrapped WSDL
will be generated.
The WRAPPED format means:
- A complexType is generated for the request and response.
- The complexType for the request has the same name as the operation.request
and contains elements for each input parameter.
- The complexType for the response is the name of the operation
+ "Response" and contains elements for each output.
- The request message references the request complexType with a
single part named "body".
- Data type
- String.
- Units
- Not applicable.
- Default
- RPC.
- Range
- RPC, DOCUMENT, or WRAPPED.
- -use LITERAL | ENCODED
- Determines, together with the -style argument,
which of four combinations of style and use is generated into the
WSDL, RPC/Enc, RPC/Lit, Doc/Lit, or Doc-wrapped/Lit. For more information,
see the WSDL bindings section.
- Data type
- String.
- Units
- Not applicable.
- Default
- ENCODED if style is RPC, LITERAL otherwise.
- Range
- ENCODED or LITERAL.
- --outputWsdlMode <mode>
- Generates either a WSDL service interface document or a WSDL service
implementation document, depending on the value of <mode>, which
must be Interface or Implementation respectively.
Note: The argument must be preceded by two
hyphens, otherwise it cannot be distinguished from the -output argument.
Troubleshooting
The WSDL generated by Java2WSDL
might contain unexpected elements. Review the JAX-RPC specification
for more information on the transformations performed.
You can
also create WSDL documents that, when regenerated into Java using the WSDL2Java tool, create uncompilable
output. This is because the JAX-RPC mapping from Java to WSDL is not reversible. If you encounter
this problem, check the WSDL file and modify it as necessary to get
the desired results.