WSDL2Java command
The WSDL2Java command tool creates Java classes and deployment descriptor templates from a WSDL file using the Java API for XML-based remote procedure call (JAX-RPC) 1.0 specification. See Mapping between Java language, WSDL and XML for more information.
Classes and files generated
The following kinds of classes and files are generated...
- For each portType in the WSDL document (<wsdl:portType> element tag)...
- Service Endpoint Interface
- For each service in the WSDL document (<wsdl:service> element tag)...
- Service Interface when the -role develop-client argument is specified.
- ServiceLocator when the -role deploy-client argument is specified.
This class is a WebSphere product-specific implementation of the service interface, and is not used directly.
- webservices.xml deployment descriptor template when the -role develop-server argument is specified
- ibm-webservices-bnd.xmi deployment descriptor template when the -role develop-server argument is specified.
- ibm-webservices-ext.xmi deployment descriptor template when the -role develop-server argument is specified.
- wsdlfile_mapping.xml JAX-RPC mapping file when the -role develop-client or -role develop-server is specified.
- webservicesclient.xml deployment descriptor template when the -role develop-client argument is specified.
- ibm-webservicesclient-bnd.xmi deployment descriptor template when the -role develop-client argument is specified.
- ibm-webservicesclient-ext.xmi deployment descriptor template when the -role develop-client argument is specified.
When the role is a server role, the container argument specifies which J2EE container the implementation uses. When the -role develop-server -container ejb arguments are specified, the webservices.xml, ibm-webservices-bnd.xmi, ibm-webservicesclient-ext.xmi and the mapping file are generated into the META-INF subdirectory. When the -role develop-server -container web arguments are specified, the files are generated into the WEB-INF directory.
- For each binding in the WSDL file (<wsdl:binding> element tag):
- A stub that implements the Service Endpoint Interface (deploy-client role)
- An implementation template for an enterprise bean and templates for the EJB remote interface and home interface generate when the -role develop-server and -container-ejb arguments are specified.
- An implementation template for the Java bean when the -role develop-server and -container-web arguments are specified.
- Other classes and files...
- A Java bean representing the structure of the type when the -role develop-server or -role develop-client arguments are specified for each complexType or simpleType.
- Three classes, *_Ser.java, *_Deser.java, and *_Helper.java, generate for each complexType to assist in converting the bean to SOAP and back when the -role deploy-server or -role deploy-client argument is specified.
- A *Holder.java class generates when the -role develop-server or -role develop-client arguments are specified for each out and inout parameter.
Command line syntax
The command line syntax is
WSDL2Java [arguments] WSDL-URIRequired arguments
- WSDL-URI
Specifies the location of the input WSDL document using a Universal Resource Identifier (URI). You can also use a regular file path if the WSDL file is on the local file system.
Important arguments
- -container j2ee-container
Indicates the J2EE container to be used. Valid arguments are...
- client
Indicates client container.
- ejb
Indicates enterprise JavaBean (EJB) container.
- none
Indicates no container.
- web
Indicates Web container.
If client is role, the default argument is none. If server is role, the container must be ejb or web. The same container option must be used for both development and deployment.
- -deployScope argument
Indicates how to deploy the server implementation. Valid arguments are...
- Application
Uses one instance of the implementation class for all requests.
- Request
Creates a new instance of the implementation class for each request.
- Session
Creates a new instance of the implementation class for each session.
- -genResolver
Generates an absolute-import resolver class. The purpose of this class is to record the contents of the imported WSDL files used by the WSDL URI. This class is used by the runtime. It can also be used for future WSDL2Java command runs. This is desirable when the imported WSDL files are remote and can be inaccessible or slow to access. It also eliminates the possibility that a remote WSDL file might have different contents at run time than it did at development time. The generated class is named _AbsoluteImportResolver.java. You should compile and package this class with the other Java classes generated by the WSDL2Java command.
- -help
Displays a help message and exits.
- -helpX
Displays a help message for extended options and exits. The options are...
- -all
Generates Java files for all types, even those that are not referenced.
- -debug
Prints debugging information.
- -fileNStoPkg filename
Specifies the file of namespace to package mappings. The default is NStoPKG.properties.
- -genJava argument
Generates Java files. Valid arguments are:
- IfNotExists, default
- Overwrite
- No
- -genXML argument
Generates the .xml and .xmi files. Valid arguments are...
- IfNotExists, default
- Overwrite
- No
- -password password
Specifies the login user password to access the WSDL URI.
- -testCase
Generates the template for a JUnit test case for testing a Web service.
- -user id
Specifies the login user name to access the WSDL URI.
- -inputMappingFile mapping file
Specifies the file name of the Java to WSDL mapping file.
- -NStoPkg namespace=package
By default, package names are automatically derived from the namespace strings in the WSDL file. For example, if the namespace is of the form http://x.y.com or urn:x.y.com, the corresponding package is com.y.x.
You can provide your own mapping by using the -NStoPkg argument, which you can repeat as often as necessary, once for each unique namespace mapping. For example, if there is a namespace in the WSDL file called urn:AddressFetcher2, and you want files generated from the objects in this namespace to reside in the package samples.addr, provide the -NStoPkg urn:AddressFetcher2=samples.addr argument to the WSDL2Java command.
- -output directory
Sets the root directory for emitted files.
- -role j2ee role
Specifies the J2EE development role that identifies which files to generate. Valid arguments are:
- client
Combination of develop-client and deploy-client.
- deploy-client
Generates binding files for client deployment.
- deploy-server
Generates binding files for server deployment.
- develop-client (default)
Generates files for client development.
- develop-server
Generates files for server development.
- server
Combination of develop-server and deploy-server.
- -timeout seconds
Specifies how long the WSDL2Java command should wait, in seconds, for the WSDL-URI to respond before giving up. The default is 45 seconds, -1 disables the timeout.
- -useResolver resolver-class
Specifies an absolute-import resolver class to use during parsing. This class must have been created during a previous execution of the WSDL2Java command using the -genResolver option. The class must be available in CLASSPATH.
- -verbose
Displays processing information, including the names of the generated files.
See Also
Developing a Service Endpoint Interface for a Java bean implementation