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是否合法,可以完整发布。 
命令参数说明:

  •  -cp 定义classpath
  •  -r 生成 bean的wsdl文件的存放目录
  •  -s 生成发布Web Service的源代码文件的存放目录(如果方法有抛出异常,则会生成该异常的描述类源文件)
  •  -d 生成发布Web Service的编译过的二进制类文件的存放目录(该异常的描述类的class文件)


命令范例: 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 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.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 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" 

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.


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值