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. wsdl文件结构分析

    WSDL (Web Services Description Language,Web服务描述语言)是一种XML Application,他将Web服务描述定义为一组服务访问点,客户端可以通过这些服务 ...

  2. javaweb项目中嵌入webservice--axis2

    由于最近项目中需要搭建webservice服务端,由于原项目是javaweb项目,所以需要整合.之前用cxf试了,启动老是报错,maven依赖冲突.后来索性换成axis2 百度了一圈,下面这个博客 h ...

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

    1. 简介 SoapUI是用java开发的测试web service的工具. 2. 安装 2.1. 下载地址 http://www.soapui.org/ 2.2. 安装 By downloading ...

  4. 用VisualC++建立SOAP客户端应用(一)

    用VisualC++建立SOAP客户端应用(一) SoapSerializer对象用来构建一个向Web服务发送的SOAP消息.在与服务器连接前,SoapSerializer对象必须与SoapConne ...

  5. 【转】Delphi调用webservice总结

    原文:http://www.cnblogs.com/zhangzhifeng/archive/2013/08/15/3259084.html Delphi调用C#写的webservice 用delph ...

  6. 用delphi的THTTPRIO控件调用了c#写的webservice。

    用delphi的THTTPRIO控件调用了c#写的webservice. 下面是我调试时遇到的一些问题: 1,导入wsdl文件:file--new----other----wenservice---W ...

  7. Delphi调用webservice总结

    Delphi调用webservice总结     Delphi调用C#写的webservice 用delphi的THTTPRIO控件调用了c#写的webservice. 下面是我调试时遇到的一些问题: ...

  8. WebService测试工具SoapUI

    尊重原著作:本文转载自http://gqsunrise.iteye.com/blog/1958480 1. 简介 SoapUI是用java开发的测试web service的工具. 2. 安装 2.1. ...

  9. onvif实现

    前言 负责开发了公司的onvif,一个人从0开始写的,花了两个月 !!!下面是我的总结. onvif介绍 ONVIF[Open Network Video Interface Forum](开放型网络 ...

随机推荐

  1. Entity Framework 6 Recipes 2nd Edition(10-8)译 - >映射插入、修改、删除操作到存储过程

    10-8. 映射插入.修改.删除操作到存储过程 问题 想要映射插入.修改.删除操作到存储过程 解决方案 假设已有运动员实体模型,如Figure 10-8所示. 对应的数据库表如Figure 10-9所 ...

  2. Alcatraz 的安装和删除

    Xcode 所有的插件都安装在目录: ~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/ 你也可以手工切换到这个目录来删除插件 ...

  3. 【PRINCE2是什么】PRINCE2认证之七大原则(5)

    我们先来回顾一下,PRINCE2七大原则分别是持续的业务验证,经验学习,角色与责任,按阶段管理,例外管理,关注产品,剪裁. 第五个原则:例外管理. PRINCE2对每个项目目标都定义了容许偏差来建立授 ...

  4. BootStrap_01之全局样式

    1.响应式网页: ①Responsive Web Page:一个可以根据浏览设备的不同,而自动更改布局.图片.文字效果的网页: ②构成:不能固定宽度,必须流式布局:文字和图片大小随容器大小而改变:CS ...

  5. <a>与文件下载-(下载一)

    <a>可直接下载xls,doc,rar,zip,exe,js文件(图片跟txt文件是直接打开的) <a href="wKioJlJolKeCIzkCADd3Wf7OPI42 ...

  6. 记2016腾讯 TST 校招面试经历,电面、笔试写代码、技术面、hr面,共5轮

    (出处:http://www.cnblogs.com/linguanh/) 前序: 距离  2016 腾讯 TST 校招面试结束已经5天了,3月27日至今,目前还在等待消息.从投简历到两轮电面,再到被 ...

  7. Cesium原理篇:GroundPrimitive

    今天来看看GroundPrimitive,选择GroundPrimitive有三个目的:1 了解GroundPrimitive和Primitive的区别和关系 2 createGeometry的特殊处 ...

  8. 【Android】开发中个人遇到和使用过的值得分享的资源合集

    Android-Classical-OpenSource Android开发中 个人遇到和使用过的值得分享的资源合集 Trinea的OpenProject 强烈推荐的Android 开源项目分类汇总, ...

  9. OWIN与Katana详解

    前言 我胡汉三又回来了,!!!!, 最近忙成狗,实在没空写博文,实在对不起自己,博客园上逛了逛发现 我大微软还是很给力的 asp.net core 1.0 .net core 1.0 即将发布,虽然. ...

  10. Java进击C#——语法之线程同步

    上一章我们讲到关于C#线程方向的应用.但是笔者并没有讲到多线程中的另一个知识点--同步.多线程的应用开发都有可能发生脏数据.同步的功能或多或少都会用到.本章就要来讲一下关于线程同步的问题.根据笔者这几 ...