WSDL 文档解析
学习webservice,就离不了WSDL文档,他是我们开发WebService的基础,虽说,现在现在有许多WebService的开源框架使得我们可以根据WSDL生成客户端代码,但是,了解WSDL文档的结构还是有必要的。闲话不多说,我们开始进入正题。
首先,我们看一份WSDL文档。
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<!--
Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.4-b01.
-->
<!--
Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.4-b01.
-->
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://server/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://server/" name="HelloWorldImplService">
<types>
<xsd:schema>
<xsd:import namespace="http://server/" schemaLocation="http://localhost:8989/HelloWorld?xsd=1"/>
</xsd:schema>
</types>
<message name="sayHello">
<part name="parameters" element="tns:sayHello"/>
</message>
<message name="sayHelloResponse">
<part name="parameters" element="tns:sayHelloResponse"/>
</message>
<portType name="HelloWorldImpl">
<operation name="sayHello">
<input wsam:Action="http://server/HelloWorldImpl/sayHelloRequest" message="tns:sayHello"/>
<output wsam:Action="http://server/HelloWorldImpl/sayHelloResponse" message="tns:sayHelloResponse"/>
</operation>
</portType>
<binding name="HelloWorldImplPortBinding" type="tns:HelloWorldImpl">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="sayHello">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="HelloWorldImplService">
<port name="HelloWorldImplPort" binding="tns:HelloWorldImplPortBinding">
<soap:address location="http://localhost:8989/HelloWorld"/>
</port>
</service>
</definitions>
这份文档就是我的上一篇文章,自己开发WebService的那个WSDL文档,咱们今天就以他为例进行讲解。
首先,对于一份WSDL文档,无论他多么复杂,都是由下面5个元素组成。
<types> <message> <portType> <bingding> <service>
首先,说一下,这个 <types> 它里面定义的是标签结构,在上述WSDL文档中的schema节点中的内容是
<xsd:import namespace="http://server/" schemaLocation="http://localhost:8989/HelloWorld?xsd=1"/>
就是说他有导入了一个xsd文件,我们可以在浏览器中访问这个schemaLocation,会出现下面的内容
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<!--
Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.4-b01.
-->
<xs:schema xmlns:tns="http://server/" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" targetNamespace="http://server/">
<xs:element name="sayHello" type="tns:sayHello"/>
<xs:element name="sayHelloResponse" type="tns:sayHelloResponse"/>
<xs:complexType name="sayHello">
<xs:sequence>
<xs:element name="arg0" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="sayHelloResponse">
<xs:sequence>
<xs:element name="return" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
首先他有一个元素叫做sayHello,他的结构应该是这样的
<sayHello>
<arg0>string</arg0>
</sayHello>
同样,元素 sayHelloResponse,他的结构应该是
<sayHelloResponse>
<return>string</return>
</sayHelloResponse>
在<types>中就是定义了上面的文件格式。
<message> 用来定义消息的结构 soap消息 ,part : 指定引用types中定义的标签片断
<portType>
portType: 用来定义服务器端的SEI
operation : 用来指定SEI中的处理请求的方法
input : 指定客户端应用传过来的数据, 会引用上面的定义的<message>
output : 指定服务器端返回给客户端的数据, 会引用上面的定义的<message>
<bingding>
binding : 用于定义SEI的实现类
type属性: 引用上面的<portType>
<soap:binding style="document"> : 绑定的数据是一个document(xml)
operation : 用来定义实现的方法
<soap:operation style="document" /> 传输的是document(xml)
input: 指定客户端应用传过来的数据
<soap:body use="literal" /> : 文本数据
output : 指定服务器端返回给客户端的数据
<soap:body use="literal" /> : 文本数据
<service>
service : 一个webservice的容器
name属性: 它用一指定客户端容器类
port : 用来指定一个服务器端处理请求的入口(就SEI的实现)
binding属性: 引用上面定义的<binding>
address : 当前webservice的请求地址
明白了WSDL文档中的元素对应关系,我们就可以这么说,portType里写的是服务器端的“干” ,bingding是客户端的“肉”,service 是帮助客户端来找到这个拥有服务端“干”的“肉”。
WSDL 文档解析的更多相关文章
- (二)发布第一个WebService服务与DSWL文档解析
1. 编写接口 package service; import javax.jws.WebService; /** * 第一个webservice服务, * @WebService注解表示这是一个we ...
- JavaScript : DOM文档解析详解
JavaScript DOM 文档解析 1.节点(node):来源于网络理论,代表网络中的一个连接点.网络是由节点构成的集合 <p title=“a gentle reminder”> ...
- ios-XML文档解析之SAX解析
首先SAX解析xml *xml文档的格式特点是节点,大体思路是把每个最小的子节点作为对象的属性,每个最小子节点的'父'节点作为对象,将节点转化为对象,输出. 每个节点都是成对存在的,有开始有结束.有始 ...
- 【Web Service】WSDL文档
WSDL文档仅仅是一个简单的XML文档. 它包含一系列描述某个web service的定义. WSDL WSDL 是基于 XML 的语言,用于描述 Web services 以及如何访问它们. WSD ...
- Android XML文档解析(一)——SAX解析
---------------------------------------------------------------------------------------------------- ...
- jsoup -- xml文档解析
jsoup -- xml文档解析 修改 https://jsoup.org/cookbook/modifying-data/set-attributes https://jsoup.org/cookb ...
- iOS网络编程笔记——XML文档解析
今天利用多余时间研究了一下XML文档解析,虽然现在移动端使用的数据格式基本为JSON格式,但是XML格式毕竟多年来一直在各种计算机语言之间使用,是一种老牌的经典的灵活的数据交换格式.所以我认为还是很有 ...
- 利用wsdl.exe自动将wsdl文档转换为C#代码
1.获取完整的wsdl文档 获取下面这个博客中提到的wsdl http://www.cnblogs.com/LCCRNblog/p/3716406.html 将获取到的wsdl放到一个文本中,改后缀( ...
- webservice学习01:wsdl文档结构
webservice学习01:wsdl文档结构 wsdl文档结构 WSDL文档示例 <wsdl:definitions xmlns:xsd="http://www.w3.org/200 ...
随机推荐
- iOS 常用控件集合 完整项目
[Swift]高仿 爱范儿3.0 http://www.code4app.com/forum.php?mod=viewthread&tid=10053&page=1&extra ...
- 理解C#系列 / 核心C# / 常量
常量 常量? 我对常量的理解就是在初始化完成后再也不变的“全局变量”. 定义常量 [const][空格][变量类型][空格][变量名称][=][值][:] const表示定义的是常量. 常量特点 常量 ...
- QThread多线程编程经典案例分析
传统的图形界面应用程序都只有一个线程执行,并且一次执行一个操作.如果用户调用一个比较耗时的操作,就会冻结界面响应. 一个解决方法是按照事件处理的思路: 调用 Void QApplication::pr ...
- Codevs 1063 合并果子
时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题目描述 Description 在一个果园里,多多已经将所有的果子打了下来,而且按果子的不同种类分 ...
- OpenGL第12-14讲小结
首先要为自己为什么没有写第10讲的控制3D场景和第11讲的红旗飘飘呢?因为没看啊~哈哈哈,而且我尝试着运行红旗飘飘的时候电脑蓝屏了(可能不是它的锅),暂时跳过了. 恩,12到14主要了解了这么些东西, ...
- C++ 11 之初始化
1.4中不同初始化的形式 a.string s("zhl").int i(3); //括号初始化 b.string s="zhl".int ...
- n盏灯亮灭问题
前几天看了华为的一个上机操作题,讲得是n盏灯亮灭问题,本质上还是数学问题,感觉很有趣,和大家分享一下,问题描述如下: 有n盏灯排成一排,依次标号1,2,…,n,每盏灯都有一根拉线开关,最初电灯都是关着 ...
- Mysql表基本操作
一. 创建表的方法 语法:create table 表名( 属性名数据类型完整约束条件, 属性名数据类型条完整约束件, ......... 属性名数据类型 ); (1)举例:1 create tabl ...
- xml操作
一.LINQ to XML 编程基础 1.LINQ to XML类 System.Xml.Linq命名空间含有19个类,下表列出了它们的名称及其描述: 类 描述 XAttribute 表示一个 XML ...
- RHEL安装docker-compose
Note that Compose 1.5.2 requires Docker 1.7.1 or later. pip install docker-compose==1.5.2 Note that ...