/**
* type元素,定义了交换信息的数据格式。
* 为了实现最大的互操作性(interoperability)和平台中立性(neutrality),WSDL选用
XML Schema DataTypes
* 简称XSD作为标准类型系统,并将它作为固有类型系统。
* 下面是数据定义部分,该部分定义了两个元素,一个是sayHello,一个是
sayHelloResponse:
* sayHello:定义了一个复杂类型,仅仅包含一个简单的字符串,将来用来描述操作的参
入传入部分;
* sayHelloResponse:定义了一个复杂类型,仅仅包含一个简单的字符串,将来用来描述
操作的返回值;
*/
http://localhost:8080/xfire/services/HelloService?wsdl
http://localhost:8080/xfire/services/HelloService?wsdl
http://localhost:8080/xfire/services/HelloService?wsdl
http://localhost:8080/xfire/services/HelloService?wsdl
http://localhost:8080/xfire/services/HelloService?wsdl
http://localhost:8080/xfire/services/HelloService?wsdl
http://localhost:8080/xfire/services/HelloService?wsdl
/**
* message元素指定XML 数据类型组成消息的各个部分。message元素用于定义操作的
输入和输出参数。
* 该部分是信息格式的抽象定义:定义了两个消息sayHelloResponse和sayHelloRequest:
* sayHelloRequest:sayHello操作的请求消息格式,由一个消息片断组成,名字为
parameters,
* 元素是我们前面定义的 types中的元素;
* sayHelloResponse:sayHello操作的响应消息格式,由一个消息片断组成,名字为
parameters,
* 元素是我们前面定义 *的types中的元素;
* 如果采用RPC样式的消息传递,只需要将文档中的element元素应以修改为type即可。
*/
http://localhost:8080/xfire/services/HelloService?wsdl
http://localhost:8080/xfire/services/HelloService?wsdl
/**
* portType元素中定义了Web服务的操作。操作定义了输入和输出数据流中可以出现的
XML消息。
* 一些抽象操作的集合。每个操作关联一个输入消息和一个输出消息。
* portType定义了服务的调用模式的类型,这里包含一个操作sayHello方法,同时包含
input和output表明
* 该操作是一个 请求/响应模式,请求消息是前面定义的sayHelloRequest,
* 响应消息是前面定义的 sayHelloResponse。input表示传递到Web服务的有效负载,
* output消息表示传递给客户的有效负载。
*/
http://localhost:8080/xfire/services/HelloService?wsdl
http://localhost:8080/xfire/services/HelloService?wsdl
/**
* binding 元素描述特定服务接口的协议、数据格式、安全性和其它属性。
* 针对操作和portType中使用的消息指定实际的协议和数据格式规范。
*/
http://localhost:8080/xfire/services/HelloService?wsdl
http://localhost:8080/xfire/services/HelloService?wsdl
http://localhost:8080/xfire/services/HelloService?wsdl
/**
* service元素。服务元素包含一组port元素。端口将端点与来自服务接口定义的binding 元
素关联起来。
* port指定一个绑定的地址,这样定义一个通信的终端。
*/
http://localhost:8080/xfire/services/HelloService?wsdl
http://localhost:8080/xfire/services/HelloService?wsdl
可以直接进入 bin 目下,运行 wsdl2java,需要注意的他的几个参数
我测试时直接运行的以下命令:
写道
wsdl2java -p com.zzzl.webservice.qidian -d d:\cxfoutput\src
-all http://game.qidian.com/RemoteWebService/IPreventIndulge.asmx?wsdl
参数说明:
-p 也就是 package 对应 java 中的包
-d 输入目录,生成.java 文件会在该目录,会自动添加-p 参数配置的包路径
-client 生成客户端测试 web service 的代码.
-server 生成服务器启动 web service 的代码.
-impl 生成 web service 的实现代码.
-ant 生成 build.xml 文件.
-all 生成上面-client -server -impl -ant 对应的所有文件.
最后这个中个 URL 对应的就是 wsdl 文件访问地址了,如果 wsdl 文件在本地也可以的.
http://game.qidian.com/RemoteWebService/IPreventIndulge.asmx?wsdl