微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

wsgen与wsimport命令简单说明

wsgen 
wsgen 是在JDK的bin目录下的一个exe文件(Windows版),该命 令的主要功能是用来生成合适的JAX-WS。它读取Web Service的终端类文件,同时生成所有用于发布Web Service所依赖的源代码文件和经过编译过的二进制类文件。这里要特别说明的是,通常在Web Service Bean中用到的异常类会另外生成一个描述Bean,如果Web Service Bean中的方法有申明抛出异常,这一步是必需的,否则服务器无法绑定该对像。此外,wsgen 还能辅助生成WSDL和相关的xsd文件wsgen 从资源文件生成一个完整的操作列表并验证web service是否合法,可以完整发布。 
命令参数说明:


命令范例: wsgen -cp ./bin -r ./wsdl -s ./src -d ./bin -wsdl org.jsoso.jws.server.Example 

wsimport 
wsimport也是在JDK的bin目录下的一个exe文件(Windows版),主要功能是根据服务端发布的wsdl文件生成客户端存根及框架,负责 与Web Service 服务器通信,并在将其封装成实例,客户端可以直接使用,就像使用本地实例一样。对Java而言,wsimport帮助程序员生存调用web service所需要的客户端类文件.java和.class。要提醒指出的是,wsimport可以用于非Java的服务器端,如:服务器端也许是C# 编写的web service,通过wsimport则生成Java的客户端实现。 
命令参数说明:

  •  -d 生成客户端执行类的class文件的存放目录
  •  -s 生成客户端执行类的源文件的存放目录
  •  -p 定义生成类的包名


命令范例: wsimport -d ./bin -s ./src -p org.jsoso.jws.client.ref http://localhost:8080/hello?wsdl



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

Contents

Overview

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. JAXWS 2.1.1 RI also provides a wsgen ant task,see Wsgen ant task for details.

Launching wsgen

  • Solaris/Linux
    • export JAXWS_HOME=/pathto/jaxws-ri
    • $JAXWS_HOME/bin/wsgen.sh -help
  • Windows
    • set JAXWS_HOME=c:\pathto\jaxws-ri
    • %JAXWS_HOME%\bin\wsgen.bat -help

Syntax

wsgen [options] <SEI>

The following table lists the 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 @R_543_4045@ion. Use of this option will ONLY print version @R_543_4045@ion. 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.1Xsoap1.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 particulawsdl:service name to be generated in the WSDL. Example, -servicename "{http://mynamespace/}MyService"

-portname <name>

Used only in conjunction with the wsdl:port name to be generated in the WSDL. Example,68)">-portname "{http://mynamespace/}MyPort" 

Example

wsgen -d stock -cp myclasspath stock.StockService 

This will generate the wrapper classes needed for StockService annotated with @WebService annotation inside stockdirectory.

wsgen -wsdl -d stock -cp myclasspath stock.StockService 

This will generate a SOAP 1.1 WSDL and schema for your Java class stock.StockService annotated with @WebService annotation.

wsgen -wsdl:Xsoap1.2 -d stock -cp myclasspath stock.StockService 

Will generate a SOAP 1.2 WSDL.

Note that you do not have to generate WSDL at the development time as JAXWS runtime will automatically generate a WSDL for you when you deploy your service.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐