The Java2WSDL command-line tool maps Java classes to a WSDL file for Java API for XML-based RPC (JAX-RPC) applications.
The Java2WSDL command maps a Java class to a Web Services Description Language (WSDL) file by following the Java API for XML-based Remote Procedure Call (JAX-RPC) 1.1 specification.
The Java2WSDL command accepts a Java class as input and produces a WSDL file that represents the input class. If a file exists at the output location, it is overwritten. The WSDL file that is generated by the Java2WSDL command contains WSDL and XML schema constructs that are automatically derived from the input class. You can override these default values with command-line arguments.
The Java2WSDL command is protocol independent; when you run the Java2WSDL command, you can specify command-line options that generate both SOAP and non-SOAP protocol bindings in the WSDL file. For each binding that can be generated, the Java2WSDL command has a binding generator to generate the WSDL for that binding.
Java2WSDL [argument...] class
The following command-line arguments are supported:
The Java2WSDL command locates the class in the CLASSPATH variable.
Provides the published location or the Uniform Resource Locator (URL) of the service. If this information is not provided, a warning is issued that indicates that the final published location is not determined yet. The service location is typically overridden when the Web service is deployed.
The name after the last backslash is the name of the service port, unless the name is overridden by the -servicePortName argument. The service port address location attribute is assigned the specified value. Multiple endpoint addresses can be specified. Using the -location option is recommended only if a single binding type is required. If multiple binding types are requested, protocol binding-specific location properties are passed over the command line using the -x flag.
Indicates the path and file name of the output WSDL file. If not specified, the default class.wsdl file is written into the current directory.
Specifies the input WSDL file that is used to build an output WSDL file. Information from an existing WSDL file, is specified in this option and is used with the input Java class to generate the output.
java2wsdl -bindingTypes http,ejb -implClass my.pkg.MyEJBClass my.pkg.MySEIThe following command is an example of using the -bindingTypes option to generate SOAP over HTTP and SOAP over JMS bindings:
java2wsdl -bindingTypes http,jms -implClass my.pkg.MyEJBClass my.pkg.MySEI
Specifies the WSDL style to use in the generated WSDL file. For more information about styles, see Mapping between Java, WSDL and XML. This argument is used with the -use argument.
If RPC is specified with -use ENCODED, a style=rpc/use=encoded WSDL file is generated. If RPC is specified with the -use LITERAL option, a style=rpc/use=literal WSDL file is generated. If DOCUMENT is specified with the -use LITERAL option, a style=document/use=literal WSDL file is generated.
Specifies which style and use combinations are generated into the WSDL file when used with the -style argument. The combinations are rpc and encoded, rpc and literal, or doc and literal. This setting applies to all SOAP bindings. For more information, see the Mapping between Java language, WSDL and XML.
Generates SOAP bindings for either HTTP (default) or JMS. If JMS is specified, the characters jms are appended to the WSDL file name to prevent overwriting an existing WSDL file for another transport. The transport option can be specified only once.
This option is deprecated. The -bindingTypes option replaces the -transport option, so that you can generate bindings that are non-SOAP specific.
Specifies the name to use for the portType element. If not specified, the binding name is the port type name.
Specifies the name to use for the binding element. If not specified, the binding name is the port type name.
Specifies the name of the service element.
Specifies the name of the service. If not specified, the service name is derived from the -location argument.
Indicates the target namespace for the WSDL file being generated. See Mapping between Java code, WSDL and XML for the algorithm that is used to obtain the default namespace.
Specifies the mapping of a Java package to a namespace. If a package does not have a namespace, the Java2WSDL command generates a namespace name. You can repeat the -PkgtoNS argument to specify mappings for multiple packages.
Specifies other classes that are represented in the WSDL file.
The Java2WSDL command uses method parameter names to construct the WSDL file message part names. The command automatically obtains the message names from the debug information in the class. If the class is compiled without debug information, or if the class is an interface, the method parameter names are not available. In this case, you can use the -implClass argument to provide an alternative class from which to obtain method parameter names. The impl-class does not need to implement the class if the class is an interface, but it must implement the same methods as the class.
Displays verbose messages.
Displays the help message.
Displays the help message for extended options and for various options that are supported by binding generators.
Specifies whether to generate the WSDL file according to wrapped rules. This option is valid if use is literal only. The option defaults to true.
The Java2WSDL command searches inherited classes and interfaces to construct the list of methods for WSDL file operations if the -all argument is specified.
The Java2WSDL command searches inherited classes and interfaces when generating extended complexTypes. The search stops when a class or an interface is found within a package that begins with java or javax. You can use the -stopClasses argument to define additional classes that cause the search to stop.
Specifies a list of method names from the Service Endpoint Interface that must be exposed in the output WSDL file. The list is separated by spaces or commas.
Sets the soapAction field according to the deployment information.
Sets the soapAction field to double quotes ("").
Sets the soapAction field to the operation name.
Specifies if you want an interface and implementation WSDL file emitted.
Location of the interface WSDL file if you use the -outputImpl argument.
Timearget namespace for the implementation WSDL file, if you use the -outputImpl argument.
Specifies the Multipurpose Internet Mail Extensions (MIME)- type used to map to Web Services-Interoperability (WS-I) SOAP with attachments reference (wsi:swaRef) for the binding element. <style> can be one of the following:
extraClasses=com.ibm.Class1, com.sun.Class2,org.apache.Class3
Methods with void returns are one-way. This argument is the default for a JMS transport.
Methods with void returns are two-way. This argument is the default for an HTTP transport.
Displays debug messages.
java2wsdl -x prop1=value1 -x prop2=value2is equivalent to:
java2wsdl -x prop1=value1,prop2=value2The -x option provides flexibility to specify each command-line option for each binding generator individually, if required. The value specified in the -x option overrides the value that is specified in the equivalent command-line option if both are specified.
Review the API documentation for a complete list
of APIs. You can also review several articles about the development of Web
services at Web
services: Resources for learning.