WSDL(Web Services Description Language,Web服务描述语言)是为描述Web Services发布的XML格式。W3C组织没有批准1.1版的WSDL,但是2.0版本已经在製訂中,2.0版将被作为推荐标准(recommendation)(一种官方标准),并将被W3C组织批准为正式标准。WSDL描述Web服务的公共接口。这是一个基于XML的关于如何与Web服务通讯和使用的服务描述;也就是描述与目录中列出的Web服务进行交互时需要绑定的协议和信息格式。通常采用抽象语言描述该服务支持的操作和信息,使用的时候再将实际的网络协议和信息格式绑定给该服务。

WSDL 文档仅仅是一个简单的 XML 文档。它包含一系列描述某个 web service 的定义。

WebMthod的定义:

 1:  [WebService(Namespace = "http://tempuri.org/")]
 2:  [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
 3:  [System.ComponentModel.ToolboxItem(false)]
 4:  public class WebService2 : System.Web.Services.WebService
 5:  {
 6:      [WebMethod]
 7:      public bool Add(TestClass testClass,int id)
 8:      {
 9:          return true;
10:      }
11:  }
12:   
13:  public class TestClass
14:  {
15:      public int a;
16:      public string b;
17:      public DateTime c;
18:  }
19:   

WSDL的结构:

一个WSDL文档通常包含有以下元素,即types、message、portType、operation、binding、 service元素。这些元素嵌套在definitions元素中。

definitions是WSDL文档的根元素,definitions还声明各命名空间。

types,数据类型定义的容器,它使用某种类型系统(一般地使用XML Schema中的类型系统)。

 1:    <wsdl:types>
 2:      <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
 3:        <s:element name="Add">
 4:          <s:complexType>
 5:            <s:sequence>
 6:              <s:element minOccurs="0" maxOccurs="1" name="testClass" type="tns:TestClass" />
 7:              <s:element minOccurs="1" maxOccurs="1" name="id" type="s:int" />
 8:            </s:sequence>
 9:          </s:complexType>
10:        </s:element>
11:        <s:complexType name="TestClass">
12:          <s:sequence>
13:            <s:element minOccurs="1" maxOccurs="1" name="a" type="s:int" />
14:            <s:element minOccurs="0" maxOccurs="1" name="b" type="s:string" />
15:            <s:element minOccurs="1" maxOccurs="1" name="c" type="s:dateTime" />
16:          </s:sequence>
17:        </s:complexType>
18:        <s:element name="AddResponse">
19:          <s:complexType>
20:            <s:sequence>
21:              <s:element minOccurs="1" maxOccurs="1" name="AddResult" type="s:boolean" />
22:            </s:sequence>
23:          </s:complexType>
24:        </s:element>
25:      </s:schema>
26:    </wsdl:types>

types描述WebMethod的名称(Add),传入参数(testClass——包括对TestClass的详细描述,id),响应信息(AddResponse)。

message描述通信消息的数据结构的抽象类型化定义,使用types的描述的类型来定义整个消息的数据结构。

1:    <wsdl:message name="AddSoapIn">
2:      <wsdl:part name="parameters" element="tns:Add" />
3:    </wsdl:message>
4:    <wsdl:message name="AddSoapOut">
5:      <wsdl:part name="parameters" element="tns:AddResponse" />
6:    </wsdl:message>

portTypeoperation描述服务和服务的方法。operation包括输入和输出(使用message的描述)。

1:    <wsdl:portType name="WebService2Soap">
2:      <wsdl:operation name="Add">
3:        <wsdl:input message="tns:AddSoapIn" />
4:        <wsdl:output message="tns:AddSoapOut" />
5:      </wsdl:operation>
6:    </wsdl:portType>

binding描述Web Services的通信协议。 <soap:binding/>描述使用SOAP协议,binding还描述Web Services的方法、输入、输出。

 1:    <wsdl:binding name="WebService2Soap" type="tns:WebService2Soap">
 2:      <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
 3:      <wsdl:operation name="Add">
 4:        <soap:operation soapAction="http://tempuri.org/Add" style="document" />
 5:        <wsdl:input>
 6:          <soap:body use="literal" />
 7:        </wsdl:input>
 8:        <wsdl:output>
 9:          <soap:body use="literal" />
10:        </wsdl:output>
11:      </wsdl:operation>
12:    </wsdl:binding>

service描述Web Services访问点的集合。因为包括SOAP1.1和SOAP1.2的描述,所以一个方法有对应两描述。

1:    <wsdl:service name="WebService2">
2:      <wsdl:port name="WebService2Soap" binding="tns:WebService2Soap">
3:        <soap:address location="http://localhost:1552/WebService2.asmx" />
4:      </wsdl:port>
5:      <wsdl:port name="WebService2Soap12" binding="tns:WebService2Soap12">
6:        <soap12:address location="http://localhost:1552/WebService2.asmx" />
7:      </wsdl:port>
8:    </wsdl:service>

【转】WebServices:WSDL的结构分析相关推荐

  1. webservice中wsdl文件说明

    wsdl文件结构分析 WSDL (Web Services Description Language,Web服务描述语言)是一种XML Application,他将Web服务描述定义为一组服务访问点, ...

  2. 利用SoapUI 测试web service的方法介绍

    http://boyun.sh.cn/blog/?p=1076 1. 简介 SoapUI是用java开发的测试web service的工具. 2. 安装 2.1. 下载地址 http://www.so ...

  3. Delphi WebService 的编写、调试、发布(IIS)、调用

    下面说明如何编写用于IIS发布的ISAPI类型的WebService. 1. New|Other|WebServices|SOAP Server Application|这里先选择建立Web App ...

  4. 软考倒计时27天:信息系统集成专业技术知识

    2014-04-27 14:09:38      多云          距软考还有27天!当一个人先从自己的内心开始奋斗,他就是个有价值的人. 1.信息系统集成的显著特点: 2.信息系统集成的分类 ...

  5. java中web错误返回码,关于在java程序里调用webservice报500返回码的有关问题

    关于在java程序里调用webservice报500返回码的问题 我现在写了个程序,是调用webservice的,执行后我打印返回码是500  错误信息是 java.io.IOException: S ...

  6. webservice Xfier

    注释:在这里我只是写了一个简单程序 第一步:导入包 第二步:在web.xml中配置xfire servlet如下代码: <!-- 配置XFire --><servlet>< ...

  7. java flash 压缩_JAVA系统下的FLASH,FLV视频应用解决方案

    最近网络上FLV视频应用越来越多了.使用这种方案的好处是:一定程度上可以保护作品版权,易于视频作品在网络上传播,更高的商业运作价值.这一切特点都是因为FLV是基于FLASH播放器的一种流媒体格式. 我 ...

  8. VMware vSphere Web Services SDK编程指南(一)-SDK简介

    vSphere Web Services SDK 简介 VMware vSphere® Web Services SDK 包含了与VMware vSphere API一起工作所需的所有组件,如 WSD ...

  9. java xfire指定参数名_Java编程中使用XFire框架调用WebService程序接口

    JAVA调用webservice,当你刚开始接触的时候你会觉得它是一个恶梦,特别是没有一个统一的标准实现,比起.net的那些几步就可以完成的webservice实现,我们看着JAVA的实现真是伤心啊. ...

最新文章

  1. 基因组行业重大事件介绍
  2. Dreamwerver8下定义表单实现第一个登陆页面
  3. cmake交叉编译android,CMake Android 交叉编译
  4. 学完python_学完Python都可以做什么
  5. android百分比布局适配,安卓屏幕适配-百分比布局
  6. 互联网和大数据是什么意思_何为互联网大数据?为什么每个人在数据的面前,相当于一丝不挂?...
  7. E20180219-hm-xa
  8. 铺磁砖,给定M*N的格子,用u*v的瓷砖去铺满,有多少种铺法
  9. Android与IOS异同点对照(1)------ 显示
  10. Python Logging Formatter
  11. 读取CSV文件并将值存储到数组中
  12. 第二季-专题10-C语言环境初始化
  13. 研磨设计模式之《观察者模式observer》
  14. 标准情况下绝对湿度与相对湿度excel表
  15. 阿里云服务器搭建及宝塔面板安装(图文教程)
  16. 计算机专业应届生简历英语作文,计算机专业毕业生英文简历范文
  17. 色拉英语第2集第4幕: Cheers! ….hiccup
  18. Codeforces Round #101 (Div. 2)
  19. 图论中握手定理的详细解释
  20. 大数据开发工程师都需要学什么?

热门文章

  1. python 遗传算法 agv_基于改进遗传算法的AGV路径规划
  2. DropBox 超实用的免费文件网络同步、备份、分享工具
  3. 基于web的工作流设计器(多比图形控件)
  4. VistaDB 数据库,.NET的新选择
  5. [剑指offer][JAVA]面试题第[12]题[矩阵的路径][DFS][剪枝]
  6. jdbc获取clob图片_jdbc方式读取oracle的clob字段实例
  7. 计算机用户名登陆管理员权限,关于win10勿删用户账号下管理员身份导致无法登录系统的问题...
  8. mysql操作窗口如何设置粘贴,Access6.5在表中复制和粘贴数据
  9. python可以测试java的代码吗_使用python做你自己的自动化测试--对Java代码做单元测试 (2)-导入第三方jar包裹...
  10. 创建实现一个简单的web项目