加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

wsgen与wsimport命令简单说明

发布时间:2020-12-17 01:14:12 所属栏目:安全 来源:网络整理
导读:wsgen ? wsgen ? 是在JDK的bin目录下的一个exe文件(Windows版),该命 令的主要功能是用来生成合适的JAX-WS。它读取Web Service的终端类文件,同时生成所有用于发布Web Service所依赖的源代码文件和经过编译过的二进制类文件。这里要特别说明的是,通常在We

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
  • Launching wsgen
  • Syntax
  • Example

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:pathtojaxws-ri
    • %JAXWS_HOME%binwsgen.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.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: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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读