# JavaTM API for XML Web Services
wsgen

Specification Version: 2.2

## wsgen

The `wsgen` tool generates JAX-WS portable artifacts used in JAX-WS web services. The tool reads a web service endpoint class and generates all the required artifacts for web service deployment, and invocation.

### Syntax

    wsgen [options] <SEI>

The following table lists the `wsgen` options.

Table 1-1 wsgen Options

Option | Description
--- | ---
`-classpath <path>` | Specify where to find input class files
`-cp <path>` | Same as `-classpath <path>`
`-d <directory>` | Specify where to place generated output files
`-extension` | allow vendor extensions (functionality not specified by the specification). Use of extensions may result in applications that are not portable or may not interoperate with other implementations
`-help` | Display help
`-keep` | Keep generated files
`-r <directory>` | Used only in conjunction with the -wsdl option. Specify where to place generated resource files such as WSDLs
`-s <directory>` | Specify where to place generated source files
`-verbose` | Output messages about what the compiler is doing
`-version` | Print version information. Use of this option will ONLY print version information. Normal processing will not occur.
`-wsdl[:protocol]` | By default `wsgen` does not generate a WSDL file. This flag is optional and will cause `wsgen` to generate a WSDL file and is usually only used so that the developer can look at the WSDL before the endpoint is deploy. The `protocol` is optional and is used to specify what protocol should be used in the `wsdl:binding`. Valid protocols include: `soap1.1` and `Xsoap1.2`. The default is `soap1.1`. `Xsoap1.2` is not standard and can only be used in conjunction with the `-extension` option.
`-servicename <name>` | Used only in conjunction with the `-wsdl` option. Used to specify a particular `wsdl:service` name to be generated in the WSDL. Example, `-servicename "{http://mynamespace/}MyService"`
`-portname <name>` | Used only in conjunction with the `-wsdl` option. Used to specify a particular `wsdl:port` name to be generated in the WSDL. Example, `-portname "{http://mynamespace/}MyPort"`

## Ant task

An Ant task for the `wsgen` tool is provided along with the tool. The attributes and elements supported by the Ant task are listed below:

        <wsgen
             sei="..."
             destdir="directory for generated class files"
             classpath="classpath" | cp="classpath"
             resourcedestdir="directory for generated resource files such as WSDLs"
             sourcedestdir="directory for generated source files"
             keep="true|false"
             verbose="true|false"
             genwsdl="true|false"
             protocol="soap1.1|Xsoap1.2"
             servicename="..."
             portname="...">
             extension="true|false"
             <classpath refid="..."/>
         </wsgen>

Attribute | Description | Command line
`sei` | Name of the service endpoint implementation class | SEI
`destdir` | Specify where to place output generated classes | `-d`
`classpath` | Specify where to find input class files | `-classpath`
`cp` | Same as `-classpath` | `-cp`
`resourcedestdir` | Used only in conjunction with the -wsdl option. Specify where to place generated resource files such as WSDLs | `-r`
`sourcedestdir` | Specify where to place generated source files | `-s`
`keep` | Keep generated files | `-keep`
`verbose` | Output messages about what the compiler is doing | `-verbose`
`genwsdl` | Specify that a WSDL file should be generated | `-wsdl`
`protocol` | Used in conjunction with `genwsdl` to specify the protocol to use in the `wsdl:binding`. Value values are `"soap1.1"` or `"Xsoap1.2"`, default is `"soap1.1".` `"Xsoap1.2"` is not standard and can only be used in conjunction with the -extensions option | `-wsdl:soap11`
`servicename` | Used in conjunction with the genwsdl option. Used to specify a particular `wsdl:service` name for the generated WSDL.Example, `servicename="{http://mynamespace/}MyService"` | `-servicename`
`portname` | Used in conjunction with the genwsdl option. Used to specify a particular `wsdl:portmame` name for the generated WSDL. Example, `portname="{http://mynamespace/}MyPort"` | `-servicename`
`extension` | allow vendor extentions (funcionality not specified by the specification). Use of extensions may result in applications that are not portable or may not interoperate with other implementations | `-extension`

The `classpath` ``attribute is a path-like structure and can also be set via nested `<classpath>``` elements. Before this task can be used, a `<taskdef>` element needs to be added to the project as given below:

      <taskdef name="wsgen" classname="com.sun.tools.ws.ant.WsGen">
          <classpath path="jaxws.classpath"/>
      </taskdef>

where `jaxws.classpath` is a reference to a path-like structure, defined elsewhere in the build environment, and contains the list of classes required by the JAX-WS tools.

### Example

    <wsgen
          resourcedestdir="${wsdl.dir}"
          sei="fromjava.server.AddNumbersImpl">
          <classpath refid="compile.classpath"/>
    </wsgen>

Copyright © Copyright © 2009, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms.