随笔-128  评论-55  文章-5  trackbacks-0
   WS-ResourceProperties协议

WS-ResourceProperties协议解决了两个问题:(1)如何描述资源状态;(2)如何操作资源状态。

WSRP使用资源属性文档来描述资源的属性,它是一个代表资源属性元素逻辑组合的XML文档。资源属性文档是资源状态的一个映射,并与WSDLportType相关联。同时WSRP还定义了一系列的消息交换格式,用于操作资源的状态:如获取、插入和修改属性等。

协议中的定义如下:

Resource Property:

l        A resource property is a piece of information defined as part of the state model of a WS-Resource.

l        A resource property may reflect a part of the resource’s state, meta-data, manageability information, etc.

Resource Properties Document:

l        The XML document representing a logical composition of resource property elements. The resource properties document defines a particular view or projection of the state data implemented by the WS-Resource.

l        The type (e.g. the XML Schema definition of the root element) of a resource properties document is associated with the WSDL portType defining the Web service interface. This association is the basis of the WS-Resource definition. Each instance of a particular WS-Resource type MUST implement a logical resource properties document of the type declared in the WSDL portType.

Resource Property Element:

l        The XML representation of a resource property.

l        A resource property element must appear as the immediate child of the root element of a resource properties document.

l        A resource property element must be an XML global element definition (GED), and is uniquely identified by QName.

Resource Property Value:

l        The value(s) associated with a resource property.

 

WS-ResourceProperties协议还定义了9种标准操作:

1.      GetResourcePropertyDocument

2.      GetResourceProperty

3.      GetMultipleResourceProperties

4.      QueryResourceProperties

5.      PutResourcePropertyDocument

6.      SetResourceProperties

7.      UpdateResourceProperties

8.      DeleteResourceProperties

9.      InsertResourceProperties

一个包含资源属性文档的Web服务必须支持GetResourceProperty消息交换方式,可以支持其它8种消息交换模式。

注意在协议中并没有定义创建资源的操作,该操作由应用程序自己定义。

关于创建 WS-Resource 的实际 SOAP 请求是非常简单的:

<SOAP-ENV:Envelope  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">

    <SOAP-ENV:Header/>

    <SOAP-ENV:Body>

        <createSatellite xmlns="http://example.com/satellite"/>

    </SOAP-ENV:Body>

</SOAP-ENV:Envelope>

我们还没有实际的对象,所以该请求到达 WSDL 文件中列出的 URI,并且我们将该请求定义为一个简单的 createSatellite 元素。

响应要稍微有意思一些。一旦您发送针对新人造卫星的请求,服务器就创建一个对新WS-Resource的引用,并以EndpointReference形式将它返回:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">

    <SOAP-ENV:Header/>

    <SOAP-ENV:Body>

       <wsa:EndpointReference  xmlns:wsa="http://www.w3.org/2005/02/addressing"

             xmlns:sat="http://example.org/satelliteSystem">

           <wsa:Address>http://example.com/satellite</wsa:Address>

           <wsa:ReferenceProperties>

               <sat:SatelliteId>SAT9928</sat:SatelliteId>

           </wsa:ReferenceProperties>

       </wsa:EndpointReference>

    </SOAP-ENV:Body>

</SOAP-ENV:Envelope>

注意,EndpointReference Address 元素指向我们在 WSDL 文件中列出的同一 URI,所以信息仍然到达相同的地方,只是量的增多。

现在我们应该注意,这不是一个普通的端点引用。 ReferenceProperties 元素展示一个标识符,该标识符最终将用于识别 WS-Resource,所以这实际上是一个 WS-Resource 限定的端点引用。我们可以使用该信息来对WS-Resource做出后续调用。

已经创建了 WS-Resource,那么我们可以对它做什么呢?

实际上,可以通过调整它的属性来做任何事情。例如,可以通过更改 altitude 属性来改变人造卫星轨道的大小。不,只是更改值并不能移动人造卫星;人造卫星的实际移动是由 Web 服务背后的应用程序决定的。但是这是 WS-Resources 所真正关心的:创建一种方式,以便通过更改属性来操纵对象。协议只是指出了如何将这些更改告诉Web服务。它不关心应用程序是如何真正操纵对象的,我们也不关心。



Author: orangelizq
email: orangelizq@163.com

欢迎大家访问我的个人网站 萌萌的IT人
posted on 2009-07-19 15:43 桔子汁 阅读(1170) 评论(0)  编辑  收藏 所属分类: Web Service

只有注册用户登录后才能发表评论。


网站导航: