WebService之WSDL文档深入分析(三)
来源:互联网 发布:用java从键盘输入 编辑:程序博客网 时间:2024/05/17 23:43
WSDL概念
WSDL(网络服务描述语言,Web Services Description Language)是一门基于 XML 的语言,用于描述 Web Services 以及如何对它们进行访问。
WSDL 文档结构
首先发布一个简单的WebService(参照:【WebService】使用JDK开发WebService(二)),在发布的WebService地址后面加上'?wsdl',得到wsdl文件地址(http://127.0.0.1:8989/test-webservice/hellows?wsdl),使用浏览器打开。
重要标签说明:
types - 数据类型(标签)定义的容器,里面使用schema定义了一些标签结构供message引用
message - 通信消息的数据结构的抽象类型化定义。引用types中定义的标签
operation - 对服务中所支持的操作的抽象描述,一个operation描述了一个访问入口的请求消息与响应消息对。
portType - 对于某个访问入口点类型所支持的操作的抽象集合,这些操作可以由一个或多个服务访问点来支持。
binding - 特定端口类型的具体协议和数据格式规范的绑定。
service- 相关服务访问点的集合
port - 定义为协议/数据格式绑定与具体Web访问地址组合的单个服务访问点。
1、文档结构
1 <definitions> 2 <types> 3 <schema> 4 <element> 5 </types> 6 7 <message> 8 <part> 9 </message>10 11 <portType>12 <operation>13 <input>14 <output>15 </portType>16 17 <binding>18 <operation>19 <input>20 <output>21 </binding>22 23 <service>24 <port>25 <address>26 </service>27 </definitions>
2、文档详解
http://127.0.0.1:8989/test-webservice/hellows?wsdl文件详解
1 <?xml version="1.0" encoding="UTF-8"?> 2 <definitions 3 xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 4 xmlns:wsp="http://www.w3.org/ns/ws-policy" 5 xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" 6 xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" 7 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 8 xmlns:tns="http://ws.test.com/" 9 xmlns:xsd="http://www.w3.org/2001/XMLSchema" 10 xmlns="http://schemas.xmlsoap.org/wsdl/" 11 targetNamespace="http://ws.test.com/" 12 name="HelloWSImplService">13 <!--14 types15 schema : 定义了一些标签结构16 -->17 <types>18 <xsd:schema>19 <!-- 此处引用的sehemaLocation地址,可以使用浏览器打开,获取schema约束 -->20 <xsd:import namespace="http://ws.test.com/" 21 schemaLocation="http://127.0.0.1:8989/test-webservice/hellows?xsd=1"></xsd:import>22 </xsd:schema>23 </types>24 25 <!--26 message : 用于定义消息的结构 soap消息27 part :指定引用types中定义的标签片段28 -->29 <message name="sayHello">30 <part name="parameters" element="tns:sayHello"></part>31 </message>32 <message name="sayHelloResponse">33 <part name="parameters" element="tns:sayHelloResponse"></part>34 </message>35 36 <!--37 portType : 用来定义服务器端的SEI38 operation : 用来指定SEI中处理请求的方法39 input : 指定客户端应用传过来的数据,会引用上面的定义的<message>40 output : 指定服务器端返回给客户端的数据,会引用上面定义的<message>41 -->42 <portType name="HelloWSImpl">43 <operation name="sayHello">44 <input wsam:Action="http://ws.test.com/HelloWSImpl/sayHelloRequest" message="tns:sayHello"></input>45 <output wsam:Action="http://ws.test.com/HelloWSImpl/sayHelloResponse" message="tns:sayHelloResponse"></output>46 </operation>47 </portType>48 49 <!--50 binding : 用于定义SEI的实现类51 type属性:引用上面的<portType>52 <soap:binding style="document"> :绑定的数据是一个document(xml)53 operation : 用来定义实现的方法54 <soap:operation style="document" /> 传输的是document(xml)55 input : 指定客户端引用传过来的数据56 <soap:body use="literal"> :文本数据57 output : 指定服务端返回给客户端的数据58 <soap:body use="literal"> :文本数据59 -->60 <binding name="HelloWSImplPortBinding" type="tns:HelloWSImpl">61 <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap:binding>62 <operation name="sayHello">63 <soap:operation soapAction=""></soap:operation>64 <input>65 <soap:body use="literal"></soap:body>66 </input>67 <output>68 <soap:body use="literal"></soap:body>69 </output>70 </operation>71 </binding>72 73 <!--74 service : 一个webservice的容器75 name属性 : 它用已指定客户端容器类76 port : 用来指定一个服务器端处理请求的入口(就是SEI的实现)77 binding属性 : 引用上面定义的<binding>78 address : 当前webservice的请求地址79 -->80 <service name="HelloWSImplService">81 <port name="HelloWSImplPort" binding="tns:HelloWSImplPortBinding">82 <soap:address location="http://127.0.0.1:8989/test-webservice/hellows"></soap:address>83 </port>84 </service>85 </definitions>
引用的http://127.0.0.1:8989/test-webservice/hellows?xsd=1, schema约束如下:
1 <?xml version="1.0" encoding="UTF-8"?> 2 <!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.4-b01. --> 3 <!-- 4 shecma约束 5 6 用于请求: 7 <sayHello> 8 <arg0>string</arg0> 9 </sayHello>10 11 用于响应:12 <sayHelloResponse>13 <return>string</return>14 </sayHelloResponse>15 16 -->17 <xs:schema xmlns:tns="http://ws.test.com/" 18 xmlns:xs="http://www.w3.org/2001/XMLSchema" 19 version="1.0" 20 targetNamespace="http://ws.test.com/">21 22 <xs:element name="sayHello" type="tns:sayHello"/>23 24 <xs:element name="sayHelloResponse" type="tns:sayHelloResponse"/>25 26 <xs:complexType name="sayHello">27 <xs:sequence>28 <xs:element name="arg0" type="xs:string" minOccurs="0"/>29 </xs:sequence>30 </xs:complexType>31 32 <xs:complexType name="sayHelloResponse">33 <xs:sequence>34 <xs:element name="return" type="xs:string" minOccurs="0"/>35 </xs:sequence>36 </xs:complexType>37 </xs:schema>
3、文档图解图
注:可以通过查看webservice的请求消息和响应消息(【WebService】使用JDK开发WebService(二)--》使用JDK开发WebService--》a、开发WebService服务端--》7、查看发送消息和响应消息的具体内容),来与wsdl文件中的message进行相互验证
转载:http://www.cnblogs.com/h--d/p/7262732.html
- WebService之WSDL文档深入分析(三)
- WebService——wsdl文档深入分析
- (3)WSDL文档深入分析
- Web Service (008---WebService WSDL文档分析)
- WebService学习笔记-WSDL文档分析
- WebService之WSDL文档元素详解 (转)
- Webservice-WSDL详解(三)
- WebService之WSDL文档元素实例详解
- java学习笔记之webservice(二)--WSDL文档及用myeclipse测试webservice
- (五) WebService-- WSDL 文档详解
- (七) WebService-- 修改WSDL文档
- webservice学习笔记(5)--WSDL文档
- WebService --WSDL文档解析
- WebService WSDL结构分析
- WebService WSDL结构分析
- WebService WSDL结构分析
- WebService WSDL结构分析 .
- WebService WSDL结构分析
- 【喜课堂-CS 架构学院管理系统 笔记】
- 移动端标签奠基石的高亮颜色或背景
- [Leetcode] 419. Battleships in a Board 解题报告
- 快速入门MapboxGL
- 51Nod 1636 教育改革
- WebService之WSDL文档深入分析(三)
- 3款强大的BootStrap的可视化制作工具推荐
- composer插件使用方法
- arm64动态链接库通过函数名获取函数偏移
- Git忽略文件不起作用解决方案
- Spring Cloud Eureka Server 高可用集群搭建
- FFmpeg3.3中codec被舍弃后,如何获取源码流的codecpar参数
- Cannot convert 临时用户 of type class java.lang.String to class java.lang.Long
- Java初阶知识总结