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

JAXWS学习(三)- wsgen和wsimport命令讲解

发布时间:2020-12-17 00:17:54 所属栏目:安全 来源:网络整理
导读:在上一篇博客中,我们使用了两个命令: wsgen -cp D:WorkSpacesWorkSpace_SSMjaxws-demotargetclasses com.deppon.demo.jaxws.service.impl.UserService -wsdl -s src -d bin -r src wsimport -keep -d bin -s src http://localhost:8080/jaxws-demo/us

在上一篇博客中,我们使用了两个命令:

wsgen -cp D:WorkSpacesWorkSpace_SSMjaxws-demotargetclasses com.deppon.demo.jaxws.service.impl.UserService -wsdl -s src -d bin -r src

wsimport -keep -d bin -s src http://localhost:8080/jaxws-demo/userService?wsdl

在这里,我们讲一下他的用法(官方文档上都有,可以直接看官方的)

1.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.

大体上就是:我们可以使用这个命令,根据Class文件,生成WSDL等相关文件

输入命令:

wsgen -help

可以显示出该命令的帮助,

当然,如果你没有配置环境变量的话,可能为提示找不到命令:

这是官方的语法讲解:

最后,简单的说一下咱们用到的几个:

(ps:执行命令时,已经进入到客户端项目的根路径下)

wsgen -cp D:WorkSpacesWorkSpace_SSMjaxws-demotargetclasses com.deppon.demo.jaxws.service.impl.UserService -wsdl -s src -d bin -r src

-cp

就是class文件的所在路径,注意一下格式,首先需要指定到class文件夹,然后加上服务的全名(包名+类名)

-wsdl

表示需要生成WSDL文件,因为默认是不生成的

-s

表示生成的源码放置的位置,生成的代码会有包名,这里放到了src下

-d

上面,我们使用-s生成了源码,这里表示源码的class文件的存放位置

-r

因为前面我们使用了-wsdl,所以需要给WSDL文件设置一个存放的路径,这里放到了src文件夹下

2.wsimport

The wsimport tool generates JAX-WS portable artifacts used in JAX-WS clients and services. The tool reads a WSDL and generates all the required artifacts for web service development,deployment,and invocation.

大体上是说,我们可以使用这个命令,根据服务,生成客户端代码

The wsimport tool generates JAX-WS portable artifacts,such as:

  • Service Endpoint Interface (SEI)

  • Service

  • Exception class mapped from wsdl:fault (if any)

  • Async Reponse Bean derived from response wsdl:message (if any)

  • JAXB generated value types (mapped java classes from schema types)

These artifacts can be packaged in a WAR file with the WSDL and schema documents along with the endpoint implementation to be deployed.?


我们简单说一下,使用到的

wsimport -keep -d bin -s src http://localhost:8080/jaxws-demo/userService?wsdl

-keep

表示生成源代码

-d

表示源代码的class文件存放的位置

-s

表示生成的源代码存放的位置


当然,在最后需要加上WSDL的访问地址

(编辑:李大同)

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

    推荐文章
      热点阅读