Generating WSDL from a Java interface or class

You can use the Java2WSDL tool to generate a WSDL document for a Java interface or class that you want to use as the basis for a web service. After generating a WSDL document with Java2WSDL, you can use the WSDL2Java tool to generate the appropriate proxy and skeleton code and deployment descriptor information for the web service; for more information, see "Generating Java code from a WSDL document".

Note:   If you compile your class with debug information, Java2WSDL uses the debug information to obtain the method parameter names.

To generate a WSDL document from a Java interface or class:

Java2WSDL command-line switches

You can use either the double dash (--) or single dash (-) versions of the following optional command-line switches:
Switch
Description
--help, -h
Prints a usage message.
--output, -o <WSDL filename>
Indicates the name of the output implementation WSDL document. If specified, Java2WSDL produces interface and implementation WSDL documents. If you use this switch, Java2WSDL ignores the --outputWSDLMode switch.
--l, -location
Indicates the URL of the service location. The name after the trailing slash or backslash is the name of the service port, unless overriden by the --service value. The service port address location attribute is assigned the specified value.
--service, -s
Indicates the name of the service. If not specified, the service name is derived from the --location value. The names of the WSDL binding, service, and port elements are derived from the service name.
--namespace, -n <target namespace>
Indicates the name of the target namespace of the WSDL document.
--PkgToNS, -p <package>=<namespace>
Indicates the mapping of a package to a namespace. If a package is encountered that does not have a namespace, Java2WSDL generates a suitable namespace name. You can specify this switch multiple times.
--methods, -m <methodname(s)>
Exports only the indicated methods in your interface class into the WSDL document. The methods list must be space or comma separated. If not specified, exports all methods declared in the interface class into the WSDL document.
--all, -a
Lets Java2WSDL look into extended classes to determine the list of methods to export into the WSDL document.
--outputWSDLMode, -w <mode> 
Indicates the type of WSDL to generate. Accepted values are:
  • All (default) Generates a WSDL document containing both interface and implementation WSDL constructs.
  • Interface Generates a WSDL document containing the interface constructs (no service element).
  • Implementation Generates a WSDL document containing the implementation. The interface WSDL is imported by using the --locationImport switch.
--locationImport, -L <url>
Indicates the location of the interface WSDL document when generating an implementation WSDL document.
--namespaceImpl, -N <namespace>
Indicates the namespace of the implementation WSDL document.
--outputImpl, -O <WSDL filename>
Outputs the specified implementation WSDL file name. When you set this switch, Java2WSDL ignores the --outputWsdlMode switch.
--factory, -f <class>
Expert switch extends and customizes Java2WSDL.
--implClass, -i <impl-class>
Java2WSDL uses method parameter names to construct the WSDL message part names. The message names are obtained from the debug information of the <class-of-portType> class file. If that class file was compiled without debug information or if <class-of-portType> is an interface, the method parameter names are unavailable. In these cases, you can use the --implClass switch to provide an alternative class from which to obtain method parameter names. The <impl-class> could be the actual implementation class, a stub class, or a skeleton class.
--exclude, -x <methodname(s)>
Excludes the the space- or comma-separated list of methods from export to the WSDL file.
--stopClasses, -c <classname(s)>
The space- or comma-separated list of class names stops the class inheritance search when you use the --all switch, which lets Java2WSDL look into extended classes to determine the list of methods to export into the WSDL document.