Java2WSDL command for JAX-RPC applications
The Java2WSDL command-line tool maps Java classes to a WSDL file for JAX-RPC applications.
(zos) The Java2WSDL command-line tool is not supported on the z/OS platform. This functionality is provided by the assembly tools provided with the z/OS version of the product.
The Java2WSDL command maps a Java class to a 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. We can override these default values with command-line arguments.
The Java2WSDL command is protocol independent; when you run the Java2WSDL command, we 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...] class
The 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
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.
(dist)(zos) The following example illustrates how to produce both SOAP over HTTP, and SOAP over Java Message Service (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
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.
- input wsdl-uri
Input WSDL file 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) and 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.MySEI
The 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
- style RPC | DOCUMENT
Specifies the WSDL style to use in the generated WSDL file. To learn more, see the Mapping between Java language, WSDL and XML for JAX-RPC applications information. 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
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. To learn more, see the Mapping between Java language, WSDL and XML for JAX-RPC applications information.
- transport http | jms
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 we 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. To learn about the algorithm used to obtain the default namespace, see the Mapping between Java language, WSDL and XML for JAX-RPC applications information.
- 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. We can repeat the -PkgtoNS argument to specify mappings for multiple packages.
- extraClasses classes
Specifies 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, we 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
Displays verbose messages.
- help
Displays the help message.
- helpX
Displays the help message for extended options and for various options that are supported by binding generators.
Other arguments
- wrapped boolean
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. We can use the -stopClasses argument to define additional classes that cause the search to stop.
- methods argument
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
Sets the soapAction field according to the deployment information.
- NONE
Sets the soapAction field to double quotes ("").
- OPERATION
Sets the soapAction field to the operation name.
- outputImpl impl-wsdl
Specifies if we 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
Target namespace for the implementation WSDL file, if you use the -outputImpl argument.
- MIMEStyle style
Specifies the 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
Sets existing options, such as -extraClasses, with a properties file instead of with a command line. Example 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
Displays debug messages.
- property or -x
We 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. We 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=value2
The -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 specified in the equivalent command-line option if both are specified.
Related concepts
Development and assembly tools
Related tasks
Implement web services applications with JAX-RPC Implement web services applications from existing WSDL files with JAX-RPC
Mapping between Java language, WSDL and XML for JAX-RPC applications WSDL2Java command for JAX-RPC applications Web services specifications and APIs