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. The generated artifacts are Java 5 compliant, making them portable across different Java versions and platforms.

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.

支援的配置 支援的配置: z/OS® 平台不支援 wsimportwsgenschemagenxjc 指令行工具。 這項功能是由隨執行於 z/OS 平台的 WebSphere® Application Server 提供的組合工具所提供。請閱讀 JAX-WS 應用程式的這些指令行工具以進一步瞭解這些工具。sptcfg
最佳作法 最佳作法: WebSphere Application Server 提供 Java API for XML-Based Web Services (JAX-WS) 和 Java Architecture for XML Binding (JAXB) 工具。 wsimportwsgenschemagenxjc 指令行工具位於 WebSphere Application Server 傳統版app_server_root\bin\ 目錄中。 xjcschemagen 指令位於 Liberty 設定檔的 app_server_root\jaxb\bin\ 目錄中。 在某些情況下,WebSphere Application Server 和 JDK 提供的工具所產生的構件,支援相同層次的規格。一般而言,JDK 工具所產生的構件可以在其他標準執行時期環境之間轉移。 不過,最好的作法是利用這個產品所提供的工具來實現在 WebSphere Application Server 環境內的緊密整合,以及使用可能只在 WebSphere Application Server 環境內受到支援的特性。 如果要利用 JAX-WS 和 JAXB 2.2 版工具,請使用在 app_server_root\bin\ 目錄內之應用程式伺服器所提供的工具。bprac
Note: wsimportwsgenschemagenxjc 指令行工具可以同時與應用程式伺服器的 Liberty 和 WebSphere Application Server 傳統版一起使用。
The wsgen tool accepts a properly annotated service endpoint implementation using the @WebService annotation as input and generates the following artifacts:
  • any additional Java Architecture for XML Binding (JAXB) classes that are required to marshal and unmarshal the message contents.
  • a WSDL file if the optional -wsdl argument is specified. The wsgen tool does not automatically generate the WSDL file.

When using JAX-WS V2.2 tools, java.lang.RuntimeException and java.rmi.RemoteException references and their subclasses are no longer mapped in the WSDL file. This behavior change complies with the JAX-WS V2.1 specification conformance rule that is described in section 3.7 of the specification. This conformance rule specifies that the java.lang.RuntimeException and java.rmi.RemoteException classes and their subclasses cannot be treated as service-specific exceptions and mapped in the WSDL file.

除了使用來自指令行的工具外,您也可以從 Ant 建置環境內,為 WebSphere Application Server 傳統版呼叫這些 JAX-WS 工具。在 Ant 建置環境中使用 com.sun.tools.ws.ant.WsGen Ant 作業可以呼叫 wsgen 工具。為了讓功能正常運作,這項 Ant 作業需要您使用 ws_ant Script 來呼叫 Ant。

避免困難 避免困難: 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 you 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.gotcha

With JAX-WS applications, the wsgen command-line tool might not locate shared class files in the full profile. You can specify the location of these class files using the com.ibm.websphere.webservices.WSDL_Generation_Extra_ClassPath custom property. For more information, see the documentation about the Java virtual machine custom properties.

Syntax

The command-line syntax is:

[Windows]
app_server_root\bin\wsgen.bat [options] service_implementation_class
[AIX][HP-UX][Linux][Solaris]
app_server_root/bin/wsgen.sh [options] service_implementation_class
[IBM i]
app_server_root/bin/wsgen [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>
Specifies the location of the service implementation class.
-cp <path>
Specifies the location of the service implementation class. This parameter is the same as -classpath <path>.
-d <directory>
Specifies where to place the generated output files.
-extension
Specifies 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
Displays the help menu.
-keep
Specifies whether to keep the generated source files.
-r <directory>
This parameter is only used with the -wsdl parameter. Specifies where to place the generated WSDL file.
-s <directory>
Specifies the directory to place the generated source files.
-verbose
Specifies to output messages about what the compiler is doing.
-version
Prints the version information. If you specify this option, only the version information is output and normal command processing does 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 with the -extension option.
-servicename <name>
This parameter is only used with the -wsdl option. Specifies a wsdl:service name to be generated in the WSDL file. For example,
-service name "{http://mynamespace/}MyService"
-portname
This parameter is only used with the -wsdl option. Specifies a wsdl:port name to be generated in the WSDL file. For example,
-portname "{http://mynamespace/}MyPort"

指出主題類型的圖示 參照主題



時間戳記圖示 前次更新: July 9, 2016 11:14
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=rwbs_wsgen
檔名:rwbs_wsgen.html