+

Search Tips   |   Advanced Search

wsgen command for JAX-WS applications


The wsgen command-line tool generates the necessary artifacts required for Java API for XML Web Services (JAX-WS) applications when starting from Java code.

When using a bottoms-up approach to develop JAX-WS Web services and you are starting from a service endpoint implementation, use the wsgen tool to generate the required JAX-WS artifacts.

Supported configurations: The wsimport, wsgen, schemagen and xjc command-line tools are not supported on the z/OS platform. This functionality is provided by the assembly tools provided with WAS running on the z/OS platform. Read about these command-line tools for JAX-WS applications to learn more about these tools.

Best practice: WebSphere provides JAX-WS and JAXB tooling. The wsimport, wsgen, schemagen and xjc command-line tools are located in...

APP_ROOT\bin\

Similar tooling is provided by the Java SE Development Kit (JDK) 6. For the most part, artifacts generated by both the tooling provided with WebSphere and the JDK are the same. In general, artifacts generated by the JDK tools are portable across compliant runtime environments. However, it is a best practice to use the WebSphere tools to achieve seamless integration within the WebSphere environment. bprac

The wsgen tool accepts a properly annotated service endpoint implementation using the @WebService annotation as input and generates the following artifacts:

Avoid trouble: The wsgen command does not differentiate the XML namespace between multiple XMLType annotations that have the same @XMLType name defined within different Java packages. When this scenario occurs, the following error is produced:

Error: Two classes have the same XML type name .... Use @XmlType.name and @XmlType.namespace to assign different names to them...
This error indicates we have class names or @XMLType.name values that have the same name, but exist within different Java packages. To prevent this error, add the @XML.Type.namespace class to the existing @XMLType annotation to differentiate between the XML types.

 

Syntax

The command line syntax is:

(Windows)

APP_ROOT\bin\wsgen.bat [options] service_implementation_class

[AIX] [HP-UX] [Linux] [Solaris]

APP_ROOT/bin/wsgen.sh [options] service_implementation_class

 

Parameters

The service_implementation_class name is the only parameter that is required.

The following parameters are optional for the wsgen command:

-classpath <path>

Location of the service implementation class.

-cp <path>

This is the same as -classpath <path>.

-d <directory>

Specifies where to place the generated output files.

-extension

Whether to enable custom extensions for functionality not specified by the JAX-WS specification. Use of the extensions can result in applications that are not portable or do not interoperate with other implementations.

-help

Display the help menu.

-keep

Whether to keep the generated source files.

-r <directory>

This parameter is only used in conjunction with the -wsdl parameter. Specifies where to place the generated WSDL file.

-s <directory>

Directory to place the generated source files.

-verbose

Specifies to output messages about what the compiler is doing.

-version

Prints the version information. If we specify this option, only the version information will be output and normal command processing will not occur.

-wsdl [:protocol]

By default, the wsgen tool does not generate a WSDL file. This optional parameter causes wsgen to generate a WSDL file and is typically only used to enable a developer to review a WSDL file before the endpoint is deployed. The protocol is optional and specifies the protocol used in the wsdl:binding. Valid values for protocol are soap 1.1 and Xsoap 1.2. The default value is soap 1.1. The Xsoap 1.2 value is not standard and is only used in conjunction with the -extension option.

-servicename <name>

This parameter is only used in conjunction with the -wsdl option. Specifies a wsdl:service name to be generated in the WSDL file. For example,

-servicename "{http://mynamespace/}MyService"

-portname

This parameter is only used in conjunction with the -wsdl option. Specifies a wsdl:port name to be generated in the WSDL file. For example,

-portname "{http://mynamespace/}MyPort"




Related concepts


Assembly tools

 

Related tasks


Generating Java artifacts for JAX-WS applications
Implement Web services applications with JAX-WS

 

Related


wsimport command for JAX-WS applications

 

Related information


Web services specifications and APIs
Java API for XML Web Services (JAX-WS) API documentation