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

webservice

发布时间:2020-12-17 01:18:19 所属栏目:安全 来源:网络整理
导读:axis-bin-1.4 根据wsdl生成客户端和服务端代码 1.wsdl to java 在Eclipse里面新建一个Java工程,导入axis-bin-1.4/ lib下面的jar包,在Eclipse中展开axis.jar。 找到 org.apache.axis.wsdl WSDL2Java.class 我们可以找里面有个main方法,右击main方法, Run A

axis-bin-1.4 根据wsdl生成客户端和服务端代码

1.wsdl to java

在Eclipse里面新建一个Java工程,导入axis-bin-1.4/ lib下面的jar包,在Eclipse中展开axis.jar。

找到 org.apache.axis.wsdl WSDL2Java.class 我们可以找里面有个main方法,右击main方法,

Run As--Run Configurations. 双击Java Application ,右击New。由下图我们可以知道

Name : 自己可以取个

Project:工程名

Main class:勾选Include system libraries when searching for a main class. 点击Search, 输入WSDL2Java就可以找到org.apache.axis.wsdl.WSDL2Java.class里面的main方法入口。

?
点击Run,在控制台输出
The wsdl URI was not specified.
Usage:? java org.apache.axis.wsdl.WSDL2Java [options] WSDL-URI
Options:
?-h,--help
??print this message and exit
?-v,--verbose
??print informational messages
?-n,--noImports
??only generate code for the immediate WSDL document
?-O,--timeout <argument>
??timeout in seconds (default is 45,specify -1 to disable)
?-D,--Debug
??print debug information
?-W,--noWrapped
??turn off support for "wrapped" document/literal
?-q,--quiet
??do not print any informational or debug messages (except err
??ors)
?-s,--server-side
??emit server-side bindings for web service
?-S,--skeletonDeploy <argument>
??deploy skeleton (true) or implementation (false) in deploy.w
??sdd.? Default is false.? Assumes --server-side.
?-N,--NStoPkg <argument>=<value>
??mapping of namespace to package
?-f,--fileNStoPkg <argument>
??file of NStoPkg mappings (default NStoPkg.properties)
?-p,--package <argument>
??override all namespace to package mappings,use this package
?? name instead
?-o,--output <argument>
??output directory for emitted files
?-d,--deployScope <argument>
??add scope to deploy.wsdd: "Application","Request","Session
??"
?-t,--testCase
??emit junit testcase class for web service
?-a,--all
??generate code for all elements,even unreferenced ones
?-T,--typeMappingVersion <argument>
??indicate 1.1 or 1.2.? The default is 1.1 (SOAP 1.1 JAX-RPC c
??ompliant.? 1.2 indicates SOAP 1.1 encoded.)
?-F,--factory <argument>
??name of a custom class that implements GeneratorFactory inte
??rface (for extending Java generation functions)
?-H,--helperGen
??emits separate Helper classes for meta data
?-B,--buildFile
??emit Ant Buildfile for web service
?-U,--user <argument>
??username to access the WSDL-URI
?-P,--password <argument>
??password to access the WSDL-URI
?-X,--classpath
??additional classpath elements
?-i,--nsInclude <argument>
??include namespace in generated code
?-x,--nsExclude <argument>
??exclude namespace from generated code
?-c,--implementationClassName <argument>
??custom name of web service implementation
?-u,--allowInvalidURL
??emit file even if WSDL endpoint URL is not a valid URL
?-w,--wrapArrays
??Prefers building beans to straight arrays for wrapped XML ar
??ray types (defaults to off).
?
这些参数介绍因版本不同可能不能。所以我们可以看看。到了这一步就是写参数的问题了
-u 我们wsdl地址,可以是本地的,也可以是网络的
-o 输入路径,如c:/ws/src
-p 报名,如com.ws
-s 生成服务端。不写的话就生成客户端了。
-t 生成测试代码。
如:客户端:-u? http:/localhost:8080/RequestNotice.asmx?WSDL? -o c:/WS/source
??????? 服务端 -u? http:/localhost:8080/RequestNotice.asmx?WSDL -s -o c:/WS/source
了解这些参数之后,点击Arguments,在Program arguments里面输入。点击Run. 如下图
我们在c:/WS/source?下面就可以看到代码了。如果是服务端的话,有对应的wsdd部署文件生成

?
?
?
2. 自己开发的Java 类以webservice形式发布。
流程:Java--->class--->wsdl--->Java---->打包---->发布
Java--->class 就不多说了
class--->wsdl. 找到Java2wsdl类的main方法,输入它的参数,然后生成。
wsdl---->Java .就是上面的了,多个参数-s。
打包Ant。下次继续

(编辑:李大同)

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

    推荐文章
      热点阅读