加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

WebServices:WSDL的结构分析

发布时间:2020-12-16 21:58:25 所属栏目:安全 来源:网络整理
导读:? ?WSDL(Web Services Description Language,Web服务描述语言)是为描述Web Services发布的XML格式。W3C组织没有批准1.1版的WSDL,但是2.0版本已经在製訂中,2.0版将被作为推荐标准(recommendation)(一种官方标准),并将被W3C组织批准为正式标准。WSDL

? ?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的结构:

image

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

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

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

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的描述)。

wsdl:binding name="WebService2Soap" type="tns:WebService2Soap">
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:        </ 8:        <wsdl:output>
 9:          <soap:body use="literal" />
11:      </12:    </wsdl:binding>

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