Introducing the Implied Resource Pattern - Resource Property Operations
(Page 3 of 7 )
WS-ResourceProperties defines four operations related to querying and updating resource properties values: GetResourceProperty, GetMultipleResourceProperties, QueryResourceProperties, and SetResourceProperties. These provide simple, standardized access to the resource properties values of a WS-Resource. Nothing prevents the designer from specifying additional operations that also read or change the WS-Resource's state. However, by defining simple, standardized access, WS-ResourceProperties enables common tooling and better composability of Web services. Let's examine how SkatesTown uses these operations.
Although these operations are defined in the WS-ResourceProperties specifications, SkatesTown includes them in its WSDL definition of its POPortType definition by copying and pasting the WSDL operations. Of course, SkatesTown uses the WSDL import element to allow these copied operations to refer to the WSDL messages and other WSDL elements defined by WS-ResourceProperties. Listing 8.2 shows the new POSubmission WSDL, which incorporates the WS-ResourceProperties concepts.
Listing 8.2 ResourceProperties Operations in the POPortType
<?xml version="1.0" ?>
<wsdl:definitions name="PurchaseOrder"
targetNamespace=
"http://www.skatestown.com/services/interfaces/
poResource.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:po="http://www.skatestown.com/ns/po"
xmlns:poR="http://www.skatestown.com/services/
interfaces/poResource.wsdl"
xmlns:poRP="http://www.skatestown.com/ns/
poResourceProperties"
xmlns:inv="http://www.skatestown.com/ns/invoice"
xmlns:wsrp="http://www.ibm.com/xmlns/stdwip/
web-services/WS-ResourceProperties"
xmlns:wsrl="http://www.ibm.com/xmlns/stdwip/
web-services/WS-ResourceLifetime"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/
soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<wsdl:import
namespace=
"http://www.ibm.com/xmlns/stdwip/web-services/
WS-ResourceProperties"
.../>
<wsdl:import
namespace=
"http://www.ibm.com/xmlns/stdwip/web-services/
WS-ResourceLifetime"
... />
<!-- Type definitions -->
<wsdl:types>
<xsd:schema
targetNamespace=
"http://www.skatestown.com/services/
interfaces/poResource.wsdl">
...
<xsd:element name="ErrorMessage"
type="xsd:string" />
<xsd:element name="POResourceID"
type="xsd:positiveInteger" />
</xsd:schema>
</wsdl:types>
<!-- Message definitions -->
<wsdl:message name="ErrorMessage">
<wsdl:part name="ErrorMessage"
element="poR:ErrorMessage"/>
</wsdl:message>
<wsdl:message name="GetInvoiceRequest" />
<wsdl:message name="GetInvoiceResponse" >
<wsdl:part name="GetInvoiceRequest"
element="inv:invoice" />
</wsdl:message>
<!-- Port type definitions -->
<wsdl:portType name="POPortType"
wsrp:ResourceProperties=
"poRP:poResourceProperties">
<wsdl:operation name="getInvoice">
<wsdl:input name="GetInvoiceRequest"
message="poR:GetInvoiceRequest" />
<wsdl:output name="GetInvoiceResponse"
message="poR:GetInvoiceResponse" />
<wsdl:fault name="NoInvoiceFault"
message="poR:ErrorMessage" />
</wsdl:operation>
<!-- ========== extends wsrp:GetResourceProperty
============ -->
<wsdl:operation name="GetResourceProperty">
<wsdl:input name="GetResourcePropertyRequest"
...
</wsdl:operation>
<!-- ===== extends
wsrp:GetMultipleResourceProperties ======= -->
<wsdl:operation name=
"GetMultipleResourceProperties">
<wsdl:input name=
"GetMultipleResourcePropertiesRequest"
...
</wsdl:operation>
<!-- ===== extends wsrp:SetResourceProperties
============ -->
<wsdl:operation name="SetResourceProperties">
<wsdl:input name=
"SetResourcePropertiesRequest"
...
</wsdl:operation>
<!-- ======= extends wsrp:QueryResourceProperties
=========== -->
<wsdl:operation name="QueryResourceProperties">
...
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>
This WSDL shows the definition for the POPortType. This definition combines an application-specific operation (GetInvoice) with WS-ResourceProperties–specific operations copied from the WS-ResourceProperties WSDL.
We can examine the details of the WS-ResourceProperties operations in the context of a PurchaseOrder WS-Resource instance. In particular, we can examine the situation where the client, The Skateboard Warehouse, has a WS-Resource–qualified endpoint reference, as shown in Figure 8.1, that it got in response to an invocation of SkatesTown's POSubmission service. The WS-Resource pointed to by that endpoint reference has resource property values as shown in Listing 8.1.
Next: GetResourceProperty >>
More Web Services Articles
More By Sams Publishing
|
This article is excerpted from chapter 8 of the book Building Web Services with Java: Making sense of XML, SOAP, WSDL, and UDDI, written by Steve Graham et al. (Sams; ISBN: 0672326418). Check it out today at your favorite bookstore. Buy this book now.
|
|