You can use the WSDL2WebService tool from a command line
to generate a web service from a WSDL file using the IBM® WebSphere® runtime
environment.
Syntax
Once you have set up your command line, you can use the
following syntax and arguments to run the tool:
To
create a skeleton web service implementation:
- Windows: WSDL2WebService
[<optional arguments>] -createService <ServiceName> -project <ProjectDir> <WSDL
URI>
- Linux: WSDL2WebService.sh
[<optional arguments>] -createService <ServiceName> -project <ProjectDir> <WSDL
URI>
Note: The final argument must be <WSDL
URI>.
To create a Web-services enabled archive:
- Windows: WSDL2WebService
[<optional arguments>] -createEar <File.ear> -project <ProjectDir>
- Linux: WSDL2WebService.sh
[<optional arguments>] -createEar <File.ear> -project <ProjectDir>
Arguments: Skeleton web service implementation
Note: The
-input option has been removed. All
imported XSD and WSDL documents must be located in the same directory
as the WSDL file specified by <WSDL URI>.
Mandatory arguments:
- -createService <ServiceName>
- Specifies a unique name for the web service. This name is used
as the context root for the web service.
- -project <ProjectDir>
- Specifies the fully-qualified path name of the target project
directory for the output. If this directory does not exist, it will
be created for you. The default is the current directory.
- - <WSDL URI>
- Specifies the location of the WSDL file describing the web service.
This may be remote or on the local file system.
Optional arguments:
- -host <HostName:PortNumber>
- Specifies the host name and port number onto which you want to
deploy the web service. The default value is localhost:6080.
- -genResolver
- Generates an import resolver, which contains all the information
from imported XSD (xml schema) files. See Note
1 for additional information about this parameter.
- -clientType <J2SE | Application | Servlet | EJB>
- Generates a skeleton implementation class for the type of client
specified. You can only use this argument in conjunction with the
-genMain argument. You cannot use this argument if you have already
specified the -server-side-only argument.
- -clientEJBName <EJB client filename>
- Uses the information in the client EJB file to configure the client-side
webservicesclient.xml descriptor with the name of the client application.
If you do not supply this argument, you must edit webservicesclient.xml
manually before adding it to the client EJB file.
- -genMain <name of main class>
- Specifies the name of the main class to generate. You can only
use this argument in conjunction with the -clientType argument. You
cannot use this argument if you have already specified the -server-side-only
argument.
- -contextRoot<ContextRoot>
- Specifies the web service's context root. The default value is <ServiceName>.
- -type <EJB | Bean>
- Generates templates specifically for either a Java™ bean or EJB implementation. The default
is to create them for a Java bean.
- -NStoPkg <list>
- Specifies a space-separated list of namespace=package mappings
that are used to override the default package names of the generated Java template classes.
- -fileNStoPkg <propertiesFile>
- Specifies the fully-qualified path name of a properties file containing
namespace=package mappings.
Note: When
using this argument, all namespace references must have the colon
':' escaped using a backslash as follows: http\://my.namespace.WSDL2WebService
ignores any namespace references that do not contain an escaped colon.
- -all
- Generates Java classes for
all the complex types defined in the WSDL document. The default is
to generate only those classes that are both defined and referenced
in the WSDL document. You use this argument only in conjunction with
the -createService argument.
- -server-side-only
- Generates server-side helper classes only. The default is to generate
server-side as well as client-side helper classes.
- - wsSecDir <directory>
- Specifies the full path to a directory containing templates to
configure the generated deployment descriptors with WS-Security information.
The directory must contain ibm-webservices-bnd.xmi and
ibm-webservices-ext.xmi files, and also ibm-webservicesclient-bnd.xmi and
ibm-webservicesclient-ext.xmi if generating
client-side bindings.
- -clientEJBName <EJB client filename>
- Uses the information in the client EJB file to configure the client-side
webservicesclient.xml descriptor with the name of the client application.
If you do not supply this argument, you must edit webservicesclient.xml
manually before adding it to the client EJB file.
- -user
- Specifies the user name to use when accessing a remote WSDL.
- -password
- Specifies the password to use when accessing a remote WSDL.
- -verbose
- Displays extra information as the tool runs.
- -help
- Displays the help information.
- -overwrite
- This will overwrite any existing service directories.
Arguments: Web-services enabled archive
Mandatory
arguments:
- -createEar <TargetFile.ear>
- Specifies the fully-qualified path name of a target EAR file.
If the path name does not exist, it will be created. If it already
exists, Web modules specified with the -add option
are added/updated as necessary.
- -project <ProjectDir>
- Specifies the fully-qualified path name of a project directory
containing one or more web service implementations to be archived.
These may have been generated by using the tool with the -createService argument.
Optional arguments:
- -add <services>
- Specifies a space-separated list of web service names to be added
to the archive. These should correspond to web service implementations
that have already been created under the specified project. If this
option is not used, all such directories are added. If a web service
module for one of these names already exists in the EAR file, it is
updated with the latest contents of the directory.
- -verbose
- Displays extra information as the tool runs.
- -help
- Displays help information.
Note:The
-deploy option is not supported.
- -rootModule <root module base name>
- Merge and aggregate individual web services of the same type into
one single module. The Web module will be named <root module base
name>_WEB.war while the EJB module will be named <root module base
name>_EJB.jar.
- -host <host name:port number>
- Replace the all web services' host name and port number. This
option must be used in conjunction with -rootModule.
Important: If you run the WSDL2WebService
command to create an EJB web service using a set of WSDL files that
do a local import the EAR file will be generated but an exception
will occur during server start-up once it is imported to the workspace
and deployed to the Unit Test Environment or a remote server. This
exception is caused by a missing WSDL in the router Web project. To
counteract this error do any of the following:
- Deploy to a stand-alone WebSphere Application
Server using the Admin Console.
- Use a monolithic WSDL - that is, do not use the -splitWsdl argument.
- Manually copy all WSDL files under the META-INF/wsdl directory
in the EJB project to the WEB-INF/wsdl of the
router Web project.
Note 1: Only select the
-genResolver argument
to bring a remote, absolute reference local so that when the web service
run, it does not have to be connected to the Internet. It should
not be used for local or relative imports. Also, the -genResolver
option should not be used on a WSDL file that contains WSDL imports
that import an XSD file. For example, instead of having a WSDL import
outside the schema element:
<import location="a.xsd" namespace="http://namespaceA"/>
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://namespaceA"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
replace it with a schema import inside the schema element:
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://namespaceA"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<import schemaLocation="a.xsd" namespace="http://namespaceA"/>