Java2WSDL command for JAX-RPC applications
The Java2WSDL command-line tool maps Java classes to a WSDL file for JAX-RPC applications.
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.
Command line syntax and arguments
The command line syntax is:Java2WSDL [argument...] classThe following command-line arguments are supported:
Required arguments
- class
Represents the fully qualified name of one of the following Java classes:
- Stateless session EJB remote interface that extends the javax.ejb.EJBObject class
- Service endpoint interface that extends the java.rmi.Remote class
- Java beans
The Java2WSDL command locates the class in the CLASSPATH variable.
Important arguments
- -location location
Published location or the 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. The following example illustrates how to produce both SOAP over HTTP, and SOAP over JMS bindings:
java2wsdl -bindingTypes http,jms \ -x http.location=http://your.server.name:9080/StockQuoteService/services/StockQuote \ -x jms.location= jms:/queue?destination=jms/MyQueue&connectionFactory=jms/MyCF&targetService=StockQuoteUse the -location option to determine to which port the -location option value applies by requiring the endpoint URLs to be specified through the binding-specific property values.
- -output wsdl-uri
Path and file name of the output WSDL file. If not specified, the default class.wsdl file is written into the current directory.
- -input wsdl-uri
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.
- -bindingTypes
List of binding types write to the output WSDL file. Each binding generator in the Java2WSDL command supports specific binding types. The valid binding type values are...
- http (SOAP over HTTP)
- jms (SOAP over JMS)
- ejb (local or remote EJB invocation)
For example, the following command can be used to generate SOAP over HTTP, EJB bindings for the...
my.pkg.MySEI...service endpoint interface and the...
my.pkg.MyEJBClass...implementation class...
java2wsdl -bindingTypes http,ejb -implClass my.pkg.MyEJBClass my.pkg.MySEITo generate SOAP over HTTP and SOAP over JMS bindings:
java2wsdl -bindingTypes http,jms -implClass my.pkg.MyEJBClass my.pkg.MySEI
- -style RPC | DOCUMENT
WSDL style to use in the generated WSDL file.
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.
- -use LITERAL | ENCODED
Specify 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
- doc and literal
This setting applies to all SOAP bindings.
- -transport http | jms
Generate 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.
- -portTypeName name
Name to use for the portType element. If not specified, the binding name is the port type name.
- -bindingName name
Name to use for the binding element. If not specified, the binding name is the port type name.
- -serviceElementName name
Name of the service element.
- -servicePortName name
Name of the service. If not specified, the service name is derived from the -location argument.
- -namespace targetNamespace
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.
- -PkgtoNS package namespace
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.
- -extraClasses classes
Specify other classes that are represented in the WSDL file.
- -implClass impl-class
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.
- -verbose
Display verbose messages.
- -help
Display the help message.
- -helpX
Display the help message for extended options and for various options that are supported by binding generators.
Other arguments
- -wrapped boolean
Specify whether to generate the WSDL file according to wrapped rules. This option is valid if use is literal only. The option defaults to true.
- -stopClasses parent [, parent]
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.
- -methods argument
Specify 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.
- -soapAction
Valid arguments are:
DEFAULT Set the soapAction field according to the deployment information. NONE Set the soapAction field to double quotes (""). OPERATION Set the soapAction field to the operation name.
- -outputImpl impl-wsdl
Specify if you want an interface and implementation WSDL file emitted.
- -locationImport location-uri
Location of the interface WSDL file if you use the -outputImpl argument.
- -namespaceImpl namespace
Timearget namespace for the implementation WSDL file, if you use the -outputImpl argument.
- -MIMEStyle <style>
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:
WSDL11 (default) Exclusively map MIME types using WSDL 1.1 standards. If the MIME type cannot map to WSDL 1.1 standards, the command fails. AXIS Map MIME types using AXIS standards, for example image becomes axis:image. swaRef Map MIME types using WSDL 1.1 standards with two caveats:
- DataHandler maps to the wsi:swaRef element instead of an application and octet-stream
- If mapping is illegal through WSDL 1.1, map to the wsi:swaRef element
- -propertiesFile argument
Set existing options, such as -extraClasses, with a properties file instead of with a command line. The following example illustrates the use of this argument:
extraClasses=com.ibm.Class1, com.sun.Class2,org.apache.Class3
- -voidReturn
Valid arguments are:
ONEWAY Methods with void returns are one-way. This argument is the default for a JMS transport. TWOWAY Methods with void returns are two-way. This argument is the default for an HTTP transport.
- -debug
Display debug messages.
- -property or -xYou can use the -x option to pass command-line options to various binding generators. Use the -x option multiple times on the command line to specify a set of property values to pass to each binding generator method called by the Java2WSDL command. You can also use a single -x option to specify multiple properties by separating them with a comma, for example:
java2wsdl -x prop1=value1 -x prop2=value2...is 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.
Related tasks
Develop a WSDL file for JAX-RPC applications
Related Reference
Map between Java language, WSDL and XML for JAX-RPC applications
WSDL2Java command for JAX-RPC applications