Presentation is loading. Please wait.

Presentation is loading. Please wait.

Web 服务描述语言 WSDL 马殿富 北航计算机学院 2006-05. 计算机学院 2 主要内容  WSDL 发展历史  WSDL 的基本属性  WSDL 的定义  WSDL 的文档框架  --类型 消息 端口类型 绑定 服务  WSDL 中的 4 种消息交换方式  WSDL 中的.

Similar presentations


Presentation on theme: "Web 服务描述语言 WSDL 马殿富 北航计算机学院 2006-05. 计算机学院 2 主要内容  WSDL 发展历史  WSDL 的基本属性  WSDL 的定义  WSDL 的文档框架  --类型 消息 端口类型 绑定 服务  WSDL 中的 4 种消息交换方式  WSDL 中的."— Presentation transcript:

1 Web 服务描述语言 WSDL 马殿富 北航计算机学院 2006-05

2 计算机学院 2 主要内容  WSDL 发展历史  WSDL 的基本属性  WSDL 的定义  WSDL 的文档框架  --类型 消息 端口类型 绑定 服务  WSDL 中的 4 种消息交换方式  WSDL 中的 4 种消息传递模式

3 计算机学院 3 发展历史  Web 服务描述语言 WSDL ( Web Services Description Language )是一个建议性标准。用于描述 Webb 服务的技 术调用语法。  1999 年 HP (惠普)公司是第一个引入 Web 服务概念, eSpeak 实现了 “ 电子服务 ” 平台。  2000 年 6 月 Microsoft 提出了 “Web 服务 ” 术语,把 Web 服务 作为.NET 计划重要组件。  在 Microsoft 的 SDL ( Service Description Language 和 SCL ( SOAP Contract Language )和 IBM 的 NASSL ( Network Accessible Service Specification Language ) 这两项技术的结合,形成了 WSDL 的基础。 SCL 采用 XML 来描述应用程序所交换的消息, NASSL 描述服务接口和实 现细节。  2000 年 9 月 25 日 IBM 、 Microsoft 和 Ariba 提出 WSDL1.0 。 2001 年 3 月 15 日,他们提交的 WSDL1.1 成为 W3C 的 Note 。 WSDL1.1 规范网址是 http://www.w3.org/TR/wsdl 。 2002 年 7 月 9 日提出 WSDL1.2 , 2003 年 11 月 10 日提出 WSDL2.0 。 http://www.w3.org/TR/wsdl WSDL1.2 WSDL2.0

4 计算机学院 4  WSDL 描述 web 服务的三个基本属性:  服务做些什么 ? 服务所提供的操作 ( 方法 ) ;  如何访问服务? 数据格式以及访问服务操作的必要协议;  服务位于何处? 由特定协议决定的网络地址,如 URL 。

5 计算机学院 5  Web 服务描述语言( Web Services Description Language WSDL )是 Web Services 技术重要组 成部分。  WSDL 描述了分布在 Internet 环境中服务操作的抽 象定义接口和服务的具体实现端口,实现远程计 算资源共享。  WSDL 通常是协议定义的,协议描述缺乏准确性和 严格性,需要一种形式化的表示和描述方法。

6 计算机学院 6 面向服务视图  规范描述资源与协议变换  实现自动服务部署和调用 Content JAVA2WSDL WSDL2JAVA UDDI 资源 服务 运行时 客户端(人) 客户端(机器) 发布 发现与定位 操作 浏览器 AJAX

7 计算机学院 7 SOAP RPC  SOAP 文档内容 5

8 计算机学院 8 服务调用 前置机 SOAP 消息 HTTP WSDL2JAVA SOAP 消息 Class Operation XML Message 服务描述 CONTEXT XML2JAVA XML Message

9 计算机学院 9 WSDL 定义  WSDL 是 XML 描述的网络服务,基于消息机制、 包含面向文本或面向过程信息的操作集合。  操作及消息的抽象定义与它们具体的网络实现和 数据格式绑定是分离的, 这样就可以重用这些抽象 定义。  消息是需要交换数据的抽象描述;  端点类型是操作的抽象集合。  针对一个特定端点类型的具体协议和数据格式规 范构成一个可重用的绑定。  一个端点定义成网络地址和可重用的绑定的联接, 端点的集合定义为服务。

10 计算机学院 10 服务接口定义和服务实现定义  服务接口组成了服务描述中的可重用部分, type 元素、 message 和 portType 。 types 元素中描述消息中复杂数据类型的使用。 message 元素指定 XML 数据类型组成消息的各 个部分。 message 元素用于定义操作的输入和 输出参数。 portType 元素中定义了 Web 服务的操作。操作 定义了输入和输出数据流中可以出现的 XML 消 息。

11 计算机学院 11 服务接口定义和服务实现定义  服务实现定义是一个描述给定服务提 供者如何实现特定服务接口的 WSDL 文档。 有 binding 和 services 。 binding 元素描述特定服务接口的协 议、数据格式、安全性和其它属性。 service 元素。服务元素包含一组 port 元素。端口将端点与来自服务接口定 义的 binding 元素关联起来。

12 计算机学院 12  WSDL 是一种 XML 应用, 它将 Web Services 描述定 义为一组服务访问端点,客户端可以通过这些服 务访问端点对包含面向文档信息或面向过程调用 的服务进行访问。  WSDL 首先对访问的操作和访问时使用的请求/响 应消息进行抽象描述,然后将其绑定到具体的传 输协议和消息格式上,以最终定义具体部署的服 务访问端点。  在具体使用中,可以使用任意的消息格式和网络 协议。  在 WSDL 规范中,定义了如何使用 SOAP 消息格式、 HTTP GET / POST 消息格式以及 MIME 格式来完 成 Web Services 交互的规范。

13 计算机学院 13 WSDL 特点  实现 Web 服务体系结构的松散耦合;  无论是请求者还是提供者可以各自独立地使用平 台、编程语言或分布式对象模型。

14 计算机学院 14 命名空间  wsdlhttp://schemas.xmlsoap.org/wsdl/http://schemas.xmlsoap.org/wsdl/  soaphttp://schemas.xmlsoap.org/wsdl/soap/http://schemas.xmlsoap.org/wsdl/soap/  httphttp://schemas.xmlsoap.org/wsdl/http/http://schemas.xmlsoap.org/wsdl/http/  mimehttp://schemas.xmlsoap.org/wsdl/mime/http://schemas.xmlsoap.org/wsdl/mime/  soapenc http://schemas.xmlsoap.org/soap/encoding/ http://schemas.xmlsoap.org/soap/encoding/  soapenv http://schemas.xmlsoap.org/soap/envelope/ http://schemas.xmlsoap.org/soap/envelope/  xsihttp://www.w3.org/2000/10/XMLSchema-instancehttp://www.w3.org/2000/10/XMLSchema-instance  xsdhttp://www.w3.org/2000/10/XMLSchemahttp://www.w3.org/2000/10/XMLSchema

15 计算机学院 15 WSDL 文档框架   *  ? ……  *  ……  *  ……  *  ……  *…… 

16 计算机学院 16 types 元素  ?  * 

17 计算机学院 17 message 元素  *  ?  <part name="nmtoken"  element="qname"? type="qname"?/> * 

18 计算机学院 18 portType 元素  *  ?  *  ?   ?   *  ? 

19 计算机学院 19 binding 元素  *  ?  *  ?  *  ?   ?  *   *  ?  * 

20 计算机学院 20 service 元素  *  ?  *  ? 

21 计算机学院 21 类型  types 元素包含了交换消息的数据类型定义。为了 实现最大的互操作性( interoperability )和平台 中立性( neutrality ), WSDL 选用 XML Schema DataTypes ,简称 XSD 作为标准类型系统,并将 它作为固有类型系统。   * 

22 计算机学院 22 类型 —XSD 编码抽象数据类型建议  使用元素( element )形式,而不使用属性 (attribute) 形式;  不包括仅在特殊的协议和数据格式中使用的元素 或者属性;  数组类型使用 Soap:Array 类型,并使用 ArrayOfXXX 作为数组类型的名;  使用 XSD 编码表示 xsd:anyType 。

23 计算机学院 23   <element name="item" type="tns:Item" minOccurs="0“  maxOccurs="unbounded"/> 

24 计算机学院 24 消息  消息由若干个逻辑部件( part )构成。每个部件使用一个消 息类型属性与某个类型系统的类型相关联。  消息定义与法如下:   *  <part name="nmtoken"  element="qname"? type="qname"?/> *   消息 (message)name 属性指定了消息的名称。  如果消息具有多个逻辑单位,则需要使用多个 part 元素。

25 计算机学院 25 消息示例 

26 计算机学院 26  s=λ(&s,"definition\*")  在 WSDL 文档中,消息名称定义具有唯一性,即  x  λ(&s,"message") (  y  λ(&s,"message","name",σ(&x,"name"))  x=y)  在消息定义中,部件名称定义具有唯一性,即  x  λ(&s,"message")  y  λ(&x,"message\part") (  z  λ(&x,"message\part","name",σ(&y,"name"))  y=z)

27 计算机学院 27  消息类型属性集合是可扩展的。 WSDL 定义如下消息类型属性  element :使用 QName 引用一个 XSD 元素,即  x  λ(&s, "message\part") (σ(&x,"element")   !y  λ(&s,"types\schema\element")   σ(&x,"element")=σ(&y,"name")))  type :使用 QName 引用个 XSD simpleType( 简单类型 ) 或 XSD complexType ( 复含类型 ) ,即  x  λ(&s,"message\part") (σ(&x,"type")   σ(&x,"type")  XSDtypes)   y  λ(&s,"types\schema\complexType")  (σ(&x,"type")=σ(&y,"name"))   y  λ(&s,"types\schema\simpleType")  (σ(&x,"type")=σ(&y,"name")))

28 计算机学院 28 端口类型定义  端口类型是一个由抽象操作和抽象消息构成的有名称的集合。   *   *   端口类型定义的 name 属性表示端口类型名称,操作定义的 name 属性 表示操作名称。

29 计算机学院 29  s=λ(&s,"definition\*")  端口类型名称具有唯一性,即  x  λ(&s,"portType") (  y  λ(&s,"portType","name",σ(&x,"name"))  x=y)  在相同端口类型中,操作名称具有唯一性,即   x  λ(&s,"portType")   y  λ(&x,"portType\operation")  (  z  λ(&x,"portType\operation","name",σ(&y,"name"))   y=z)

30 计算机学院 30  在不同的端口类型中,如果操作名称相同,则操作定义相同。  x  λ(&s,"portType\operation") (  y  λ(&s,"portType\operation","name",σ(&x,"name"))  x=y)  操作的 input 、 output 和 fault 元素的 message 属性所指定的消 息,在 WSDL 的 message 中已定义,即  x  λ(&s,"portType\operation\input")  y  λ(&s,"message")(σ(&x,"message")=σ(&y,"name"))  x  λ(&s,"portType\ operation\output")  y  λ(&s,"message")(σ(&x,"message")=σ(&y,"name"))  x  λ(&s,"portType\ operation\fault")  y  λ(&s,"message")(σ(&x,"message")=σ(&y, "name"))

31 计算机学院 31 操作  WSDL 支持 4 种消息交换方式,来访问服务端点。 单向( One-way ):服务访问端点接收消息; 请求响应( Request-response ):服务访问端点接 收请求消息,然后发送响应消息; 要求应答( Solicit-response ):服务访问端点发送 要求消息,然后接收应答消息; 通知( Notification ):服务访问端点发送通知消息。  操作中引用到的消息通过 message 属性指定。

32 计算机学院 32 单向操作  单向操作语法:   *   input 元素指定用于单向操作的抽象消息格式。

33 计算机学院 33 请求响应操作  请求响应操作语法   *  <wsdl:operation name="nmtoken"  parameterOrder="nmtokens">   * 

34 计算机学院 34 要求应答操作  要求应答操作语法   *  <wsdl:operation name="nmtoken"  parameterOrder="nmtokens">   * 

35 计算机学院 35 通知操作  通知操作语法   *   <wsdl:output name="nmtoken"?  message="qname"/> 

36 计算机学院 36 操作中的元素名称  如果单向操作和通知操作未指定 name 属性,则该 属性名默认为是操作名。  如果请求响应或要求应答操作中未指定 name 属性, 则该属性名默认为是 操作名 +“Request”/“Responese”/“Solicit” 。  针对于请求应答和要求应答操作可以通过 parameterOrder 指定一个参数名列表。该属性的 值是一个用空格分开的消息构件名序列 。

37 计算机学院 37 绑定  绑定语法如下:   *  ?   ?  *   * 

38 计算机学院 38 服务与访问端点  访问端点( port )通过为绑定指定唯一地址来定义一个访问 端点。访问端点语法如下:   *   在 WSDL 文档范围内,访问端点的 name 属性具有唯一性。

39 计算机学院 39 服务  服务是访问端点集合,服务语法如下:   *   在 WSDL 文档中,服务的 name 属性具有唯一性。

40 计算机学院 40  服务中的访问端点具有如下的关系: 所有访问端点都不相互通信,即一个服务的访问端 点的输出不会是另一个访问端点的输入。 如果一个服务中有多个访问端点属于同一端口类型, 但是对应不同的绑定或者地址,则这些访问端点可 以相互替换。这使得 WSDL 文档使用者根据需要选 择访问端点。 通过检查访问端点可以确定服务的端口类型。这使 得 WSDL 文档的使用者能够根据它支持的端口类型 决定是否与一个特定的服务通讯。

41 计算机学院 41 SOAP 绑定   ?   <soap:body parts="nmtokens"? use="literal|encoded"  encodingStyle="uri-list"? namespace="uri"?>  *   <soap:body parts="nmtokens"? use="literal|encoded"  encodingStyle="uri-list"? namespace="uri"?>  *   *  <soap:fault name="nmtoken" use="literal|encoded"  encodingStyle="uri-list"? namespace="uri"?> 

42 计算机学院 42 soap:binding 元素  SOAP:binding 元素表明 WSDL 文档绑定到 SOAP 协议格式, 该元 素在使用 SOAP 绑定时是必需的。   <soap:binding transport="uri"?  style="rpc|document"?>   style 属性值是它所包含的操作子元素的 style 属性的默认值。  transport 属性是必需的,它的值表示绑定的传输方式与 SOAP 的何种传输方式一致。 URI 值 http://schemas.xmlsoap.org/soap/http 表示传输方式和 SOAP 规范的 HTTP 绑定相一致。

43 计算机学院 43 soap:operation   <soap:operation soapAction="uri"?  style="rpc|document"?>? 

44 计算机学院 44 soap:body   <soap:body parts="nmtokens"? use="literal|encoded"?  encodingStyle="uri-list"?  namespace="uri"?>   <soap:body parts="nmtokens"? use="literal|encoded"?  encodingStyle="uri-list"? namespace="uri"?> 

45 计算机学院 45 soap:fault   *  <soap:fault name="nmtoken"  use="literal|encoded"  encodingStyle="uri-list"?  namespace="uri"?> 

46 计算机学院 46 soap:header 和 soap:headerfault   <soap:header message="qname" part="nmtoken" use="literal|encoded"  encodingStyle="uri-list"? namespace="uri"?>*  <soap:headerfault message="qname" part="nmtoken" use="literal|encoded"  encodingStyle="uri-list"? namespace="uri"?/>*   <soap:header message="qname" part="nmtoken" use="literal|encoded"  encodingStyle="uri-list"? namespace="uri"?>*  <soap:headerfault message="qname" part="nmtoken" use="literal|encoded"  encodingStyle="uri-list"? namespace="uri"?/>* 

47 计算机学院 47 soap:address 

48 计算机学院 48 portType 、 binding 与 port  一个 portType 可 以对应多个 bindng  一个 binding 可以 对应多个 port port binding port portType

49 计算机学院 49 消息传递模式  1 . rpc/encoded  2 . rpc/literal  3 . document/encoded  4 . document/literal

50 计算机学院 50 服务  public class myServices {  public void myMethod (int x){  return  }

51 计算机学院 51 rpc/encoded 样式  WSDL 文档内容

52 计算机学院 52 rpc/encoded 样式  SOAP 文档内容 5

53 计算机学院 53 2 rpc/literal 样式  WSDL 文档内容

54 计算机学院 54 2 rpc/literal 样式  SOAP 文档内容 5

55 计算机学院 55 3 document /encoded  WSDL 文档内容 

56 计算机学院 56 3 document /encoded  SOAP 文档内容   5 

57 计算机学院 57 4 . document /literal  WSDL 文档内容 

58 计算机学院 58 4 . document /literal  SOAP 文档内容   5 

59 计算机学院 59 5 document / literal-wrap  WSDL 文档   <part name="  parameters" element=" myMethod"/> 

60 计算机学院 60 5 document / literal-wrap  SOAP 文档   5 


Download ppt "Web 服务描述语言 WSDL 马殿富 北航计算机学院 2006-05. 计算机学院 2 主要内容  WSDL 发展历史  WSDL 的基本属性  WSDL 的定义  WSDL 的文档框架  --类型 消息 端口类型 绑定 服务  WSDL 中的 4 种消息交换方式  WSDL 中的."

Similar presentations


Ads by Google