webservice 之 WSDL的解析
先看一个wsdl,
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:tns="http://ws.lk.com"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://ws.lk.com">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://ws.lk.com">
<xsd:element name="example">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="" minOccurs="" name="in0"
nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="exampleResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="" minOccurs="" name="out"
nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="exampleRequest">
<wsdl:part name="parameters" element="tns:example"></wsdl:part>
</wsdl:message>
<wsdl:message name="exampleResponse">
<wsdl:part name="parameters" element="tns:exampleResponse"></wsdl:part>
</wsdl:message>
<wsdl:portType name="HelloWSsssPortType">
<wsdl:operation name="example">
<wsdl:input name="exampleRequest" message="tns:exampleRequest"></wsdl:input>
<wsdl:output name="exampleResponse" message="tns:exampleResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloWSsssHttpBinding" type="tns:HelloWSsssPortType">
<wsdlsoap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="example">
<wsdlsoap:operation soapAction="" />
<wsdl:input name="exampleRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
<wsdl:output name="exampleResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloWSsss">
<wsdl:port name="HelloWSsssHttpPort" binding="tns:HelloWSsssHttpBinding">
<wsdlsoap:address location="http://localhost:8080/HelloWS/services/HelloWSsss" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
首先通过MyEclipse 的 New web service 向导生成java代码,可以同时生成接口、实现类,然后访问http://localhost:8080/HelloWS/services/HelloWSsss?wsdl 得到的。
如果通过MyEclipse 的 MyEclipse WSDL Editor打开,则得到:

类似这样的图片,看到个很多次了,每次都是看不懂。。。 郁闷。 不过,其实要是稍微研究对应的.wsdl一下,则发现,它没那么的吓人。
基本结构就是:
wsdl:service 有wsdl:port 的子元素,wsdl:port 有子元素wsdlsoap:address 提供对外访问的url。 wsdl:port 同时由binding属性绑定了一个wsdl:binding 。
wsdl:binding 有type属性指定了wsdl:portType ,wsdl:portType 包含子元素wsdl:operation ,wsdl:operation 的name属性指定了其对外提供的方法。
子元素wsdl:input 、wsdl:output 分部对应方法的参数、返回值。wsdl:input 、wsdl:output 的message属性指定了wsdl:message ,子元素wsdl:part 的element属性指定了
包含在wsdl:types中的xsd:element ,xsd:element 子子元素的type属性指定了 具体的数据类型。
这样的描述显得混乱,但是我不太会通过绘图来分析。先这样吧。
规律:
如果是通过New web service 向导生成的, 默认的各元素属性名字,非常有规律:
假设 ws 名字为
HelloWSsss ,那么 ——> binding="tns:HelloWSsssHttpBinding" -> type="tns:HelloWSsssPortType" -> wsdl:operation name="example"
兵分两路:
-> wsdl:input name="exampleRequest" -> element="tns:example"
-> wsdl:output name="exampleResponse" -> element="tns:exampleResponse"
__ 就这样,注意到, input参数message名 为 exampleRequest ,到了element标签的时候,名字重新变回了 example, 当然,这个无关紧要,非常小的细节。。。
xsd:element -> wsdl:message -> wsdl:portType : wsdl:operation -> input 、 output 两个 wsdl:message -> 两个 xsd:element
不搞了,反正已经完全不惧怕wsdl了!!
看到那样的图,也完全不用担心看不懂了! 其实很简单,只是wsdl 这样的格式把一个非常简单的ws描述的复杂起来,当然,这也可能是为了能够处理复杂问题,而逐渐完善起来的规范。。
webservice 之 WSDL的解析的更多相关文章
- 学习 WebService 第二步:知识准备——WSDL文件解析
原文地址:https://www.cnblogs.com/yzw23333/p/7245104.html Web service中一个 WSDL 对应一个 web service地址. 可以想象成一个 ...
- java使用POST发送soap报文请求webservice返回500错误解析
本文使用JAX-WS2.2编译webservice,并使用HttpUrlConnection的POST方式对wsdl发送soap报文进行请求返回数据, 对错误Server returned HTTP ...
- [Java] webservice soap,wsdl 例子
java 调用webservice的各种方法总结 现在webservice加xml技术已经逐渐成熟,但要真正要用起来还需时日!! 由于毕业设计缘故,我看了很多关于webservice方面的知识,今天和 ...
- Webservice、WSDL三种服务访问的方式【转】
http://www.cnblogs.com/yongfeng/archive/2013/01/30/2883146.html 用soapUI试了下wsdl的测试,但还是不知道webService和W ...
- 浅淡Webservice、WSDL三种服务访问的方式(附案例)
Webservice Webservice是使应用程序以与平台和编程语言无关的方式进行相互通信技术. eg:站点提供访问的数据接口:新浪微博.淘宝. 官方解释:它是一种构建应用程序的普遍模型,可以在任 ...
- webservice接口测试wsdl,参数是xml格式。python,入参转化成str,返回值转化成dict调用
1.用SoapUI测试webservice接口,传入参数是xml格式时.xml格式需要将xml的外围增加<![CDATA[xml]]> 2.但是用python去做webservice测试, ...
- delphi 调用Webservice 引入wsdl 报错 document empty
delphi 调用Webservice 引入wsdl 报错 document empty 直接引入wsdl 地址报错 document empty 解决办法:在浏览器里保存为xml文件,然后在开发环境 ...
- wsdl 结构解析
webservice的跨平台特性要求它必须有某种手段来对服务进行自我描述,使不同的语言能正确理解如何调用该服务.webservice通过WSDL(Web Services Description La ...
- 彻底理解webservice SOAP WSDL
WebServices简介 先给出一个概念 SOA ,即Service Oriented Architecture ,中文一般理解为面向服务的架构, 既然说是一种架构的话,所以一般认为 SOA 是包含 ...
随机推荐
- 本地socket使用AF_UNIX
int socket(int domain, int type, int protocol); domain参数代表地址族,我们最常用的是TCP/IP协议通信中使用的是AF_INET,在有些情况下建立 ...
- liunx 字符编码问题
查询当前服务器的编码:echo $LANG 设置服务器的编码:LANG=en_US.UTF-8
- CentOS7下GNOME桌面的安装
1,搭建yum源仓库.(yum的配置文件在/etc/yum.repos.d目录) (详见http://www.cnblogs.com/zyh120/p/6020781.html) 2,列出yum仓库里 ...
- JAVA里面的IO流(一)分类2(节点流和处理流及构造方法概要)
IO流根据处理对象的不同分为节点流和处理流. 直接对文件进行处理的流为节点流: 对流进行包装从而实现对文件的优化处理的流为处理流. 节点流类型: 可以看出,节点流主要分这几大类: 文件流 文件流构造方 ...
- 近期C#项目中总结
1. 读写文件操作 using (file = new System.IO.StreamReader(inputfile)) { using (outfile = new System.IO.Stre ...
- gridview汇出EXCEL (ExportGridViewToExcel(dt, HttpContext.Current.Response);)
调用 ExportGridViewToExcel(dt, HttpContext.Current.Response); private void ExportGridViewToExcel(DataT ...
- 结对开发训练(郭林林&胡潇丹)
此次编程题为:求一个整数数组最大子数组之和,要求时间复杂度为O(n). 首先,我们对题目做出分析,做出第一种预行方案,即定义一个数组,当数组中元素大于等于0时,进行累加:若小于0,则与后面的数作比较, ...
- css小技巧
每逢大的灾难的时候,很多网站变成了灰色,如何让网站快速变灰?css代码是很简单的,用的是css的filter功能. html { filter: grayscale(100%);//IE浏览器 -we ...
- [转] How to Show Usual Winform as View in XAF
How to Show Usual Winform as View in XAF http://www.codeproject.com/Tips/464188/How-to-Show-Usual-Wi ...
- iOS 开发-- enum与typeof enum用法
一, 两者的用法 枚举类型定义用关键字enum标识,形式为: enum标识符 { 枚举数据表 }; enum用来定义一系列宏定义常量区别用,相当于一系列的#define ** **,当然它后面的标识符 ...