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

通过WebService接口生成WSDL文件

发布时间:2020-12-17 02:02:29 所属栏目:安全 来源:网络整理
导读:【前言】曾经也想用java代码生成wsdl,但是没有实现,转个文章过来,以后有时间研究研究 ? 【出处】http://danlley.javaeye.com/blog/101882 ? 在大多数情况下我们都需要为我们的服务提供一个WSDL文件,而 Axis2's Java2WSDL 是专门用来生成WSDL文件的专用工

【前言】曾经也想用java代码生成wsdl,但是没有实现,转个文章过来,以后有时间研究研究

?

【出处】http://danlley.javaeye.com/blog/101882

?

在大多数情况下我们都需要为我们的服务提供一个WSDL文件,而 Axis2's Java2WSDL 是专门用来生成WSDL文件的专用工具,如果你要在命令行模式下进行生成WSDL文件,首先需要保证你的环境变量AXIS2_HOME是否已经配置OK,同时还要保证把%AXIS2_HOME%/bin加入到你的path环境中,要生成 WSDL文件,首先要保证你的class能够编译成功,而且已经编译成功,然后进入class文件编译后的根目录(在JBuilder中是classes,在Eclipse中是bin目录)这时,生成WSDL文件的准备工作已经OK。
?
下面是生成WSDL文件时的可选参数和参数说明:
---------------------------------------------------------------------------------
Usage java2wsdl -cn <fully qualified class name> : class file name
-o <output Location> : output file location
?
-cp <class path uri> : list of classpath entries - (urls)
?
-tn <target namespace> : target namespace
?
-tp <target namespace prefix> : target namespace prefix
?
-stn <schema target namespace> : target namespace for schema
?
-stp <schema target namespace prefix> : target namespace prefix for schema
?
-sn <service name> : service name
?
-of <output file name> : output file name for the WSDL
?
-st <binding style> : style for the WSDL
?
-u <binding use> : use for the WSDL
?
-l <soap address> : address of the port for the WSDL
?
-nsg <generator class name> : fully qualified name of the class that implements NamespaceGenerator
?
-p2n [<java package>,<namespace] [<java package>,<namespace]... : java package to namespace mapping for argument and return types...to assign all types to a single namespace : -p2n [all,<namespace>] ...
?
-efd <qualified/unqualified> : Setting for elementFormDefault (defaults to qualified)
?
-afd <qualified/unqualified> : Setting for attributeFormDefault (defaults to qualified)
?
-xc <extra class> : Extra class for which schematype must be generated.
Use as : -xc class1 -xc class2 ...
---------------------------------------------------------------------------------
?
典型地,进入你的工程的二进制编译根目录,执行命令模板如下:
java2wsdl -cp . -cn [PACKAGENAME].[CLASSNAME]-of [FILENAME].wsdl
?
现在我们假设在samples.helloworld.service.axiom;包下面有个HelloWorldService类,工程的类文件编译后存放在build/classes目录下,那么,首先进入该目录中,然后执行以下命令:
java2wsdl -cp . -cn samples.helloworld.service.axiom.HelloWorldService -of HelloWorldService.wsdl
?
执行后的CMD提示如下说明已经成功执行了:
Using AXIS2_HOME:?? D:/axis2-1.1.1Using JAVA_HOME:??? C:/Program Files/Java/jdk1.5.0_06

(编辑:李大同)

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

    推荐文章
      热点阅读