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 是包含 ...
随机推荐
- adb devices 端口占用
一. 1.通过cmd命令,输入adb devices查看连接设备时,报错 2 .通过adb nodaemon server 查看adb server绑定的端口.提示“通过每个套接字地址只能使用一次” ...
- CAD二次开发---导入外部文件中的块并输出预览图形(五)
思路: 1)首先要定义一个数据库对象来表示包含块的文件,改数据库对象会被加载到内存中,但不会被显示在CAD窗口中. 2)调用Database类的ReadDwgFile函数将外部文件DWG文件读入到新创 ...
- C++回顾map的用法
map<T, T>是C++的STL中存储key-value键值对数据结构的最基础的模板类,相对于multimap可以重复的key值,map的key是非重复的. C++的reference这 ...
- C/C++编译链接过程详解
有些人写C/C++(以下假定为C++)程序,对unresolved external link或者duplicated external simbol的错误信息不知所措(因为这样的错误信息不能定位到某 ...
- noip2008-t3
[题目描述] 小渊和小轩是好朋友也是同班同学,他们在一起总有谈不完的话题.一次素质拓展活动中,班上同学安排做成一个m行n 列的矩阵,而小渊和小轩被安排在矩阵对角线的两端,因此,他们就无法直接交谈了.幸 ...
- 猜字符游戏之java
package days06; //需求......,问题,为什么要用do{}while???import java.util.Scanner;public class RepeatOfGussing ...
- swift禁用webView对H5中数字,链接,日期,地址,电话号码做解析
showWebView.dataDetectorTypes = .None //swift禁用webView对H5中数字,链接,日期,地址,电话号码做解析 其UIDataDetectorTypes属性 ...
- 黑马程序员-autorelease pool
Autorelease:可以延迟给对象发送release消息.发送一个autorelease消息给对象,证明该对象在一定时间内有效,一定时间后会对该对象进行释放,进行一次release. 一个auto ...
- IOS对.Net返回的Base64string解析问题
1.c#生成Base64字符串的代码 string body = "{\"title\":\"上次CVR卡其\",\"url\": ...
- linux sort,uniq,cut,wc命令详解
linux sort,uniq,cut,wc命令详解 sort sort 命令对 File 参数指定的文件中的行排序,并将结果写到标准输出.如果 File 参数指定多个文件,那么 sort 命令将这些 ...