Web サービス・リソース・フレームワークを使用したステートフル Web サービスの作成
ステートフル Web サービスを WS-Resource として実装し、WS-Addressing エンドポイント参照を使用して、それを参照することができます。WS-Resources は、通常の Web サービスと同じ方法で、同じツールを使用して開発します。ただし、このトピックで説明しているように、実行しなければならない追加のタスクがいくつかあります。
このタスクについて
このタスクは、WS-Resource を作成する場合に実行します。WS-Resource は、ステートフル・リソースと、リソースへのアクセスに使用される Web サービスの組み合わせです。このタスクを完了するには、標準 Web サービス開発タスク、および Web サービス・リソース・フレームワーク (WSRF) 仕様の知識を持っている必要があります。WSRF 仕様への入門としては、OASIS WSRF Primer 文書をお読みください。
手順
WS-Resource 用リソース・プロパティー・スキーマ文書の作成
以下の例は、この手順のステップ 2 から 4 に対応しています。 これらの例では、IT 組織が WS-Resource インスタンスを使用してプリンターのネットワークを管理する方法を示しています。 WS-Resource は、リソースと、そのリソースにアクセスするための Web サービスとの組み合わせです。 以下の例では、該当の組織が Web サービスを使用して、Web Services Addressing を使用する JAX-RPC Web サービス・アプリケーションの作成の例で設定されているようにプリンター・ネットワークを現在管理していると想定しています。
Web Services Resource Framework (WSRF) 仕様の一部である WS-Resource 仕様で記述されているように、WS-Resource へのアクセスは、WS-Addressing エンドポイント参照で行われ、 そのリソースの状態の表示内容は、リソース・プロパティー XML 文書で維持されます。 ステートフル・リソースを表記するための WS-Resource の使用によって、標準化された Web サービス・メッセージを使用して、リソースの状態表記と対話する相互作用手法が提供されます。
<?xml version="1.0"?>
<xsd:schema ...
xmlns:pr="http://example.org/printer.xsd"
targetNamespace="http://example.org/printer.xsd" >
<xsd:element name="printer_properties">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="pr:printer_reference" />
<xsd:element ref="pr:printer_name" />
<xsd:element ref="pr:printer_state" />
<xsd:element ref="pr:printer_accepting_jobs" />
<xsd:element ref="pr:queued_job_count" />
<xsd:element ref="pr:operations_supported" />
<xsd:element ref="pr:document_format_supported" />
<xsd:element ref="pr:job_hold_until_default"
minOccurs="0" />
<xsd:element ref="pr:job_hold_until_supported"
minOccurs="0"
maxOccurs="unbounded" />
<xsd:element ref="wsrf-rp:QueryExpressionDialect"
maxOccurs="unbounded" />
<xsd:element ref="pr:job_properties" minOccurs="0"
maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
...
</schema>
<wsdl:definitions targetNamespace="http://example.org/printer" ...
xmlns:wsrf-rp="http://docs.oasis-open.org/wsrf/rp-2"
xmlns:wsrf-rpw="http://docs.oasis-open.org/wsrf/rpw-2"
xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:pr="http://example.org/printer">
<wsdl:types>
...
<xsd:schema...>
<xsd:element name="CreatePrinterRequest"/>
<xsd:element name="CreatePrinterResponse"
type="wsa:EndpointReferenceType"/>
<xsd:import namespace="http://www.w3.org/2005/08/addressing"
schemaLocation="http://www.w3.org/2005/08/addressing/ws-addr.xsd"/>
<xsd:import namespace=http://docs.oasis-open.org/wsrf/rp-2
schemaLocation="http://docs.oasis-open.org/wsrf/rp-2.xsd"/>
</xsd:schema>
<!-- Import WSDL definitions for GetResourceProperties -->
<wsdl:import namespace="http://docs.oasis-open.org/wsrf/rpw-2"
location="http://docs.oasis-open.org/wsrf/rpw-2.wsdl" />
</wsdl:types>
<wsdl:message name="CreatePrinterRequest">
<wsdl:part name="CreatePrinterRequest"
element="pr:CreatePrinterRequest" />
</wsdl:message>
<wsdl:message name="CreatePrinterResponse">
<wsdl:part name="CreatePrinterResponse"
element="pr:CreatePrinterResponse" />
</wsdl:message>
<!-- The port type has a ResourceProperties attribute that references the resource
properties document -->
<wsdl:portType name="Printer" wsrf-rp:ResourceProperties="pr:printer_properties">
<wsdl:operation name="createPrinter">
<wsdl:input name="CreatePrinterRequest"
message="pr:CreatePrinterRequest" />
<wsdl:output name="CreatePrinterResponse"
message="pr:CreatePrinterResponse" />
</wsdl:operation>
<!-- The GetResourceProperty operation is required by the WS-ResourceProperties specification -->
<wsdl:operation name="GetResourceProperty"
<wsdl:input name="GetResourcePropertyRequest"
message="wsrf-rpw:GetResourcePropertyRequest"
wsa:Action="http://docs.oasis-open.org/wsrf/rpw-2/GetResourceProperty/
GetResourcePropertyRequest"/>
<wsdl:output name="GetResourcePropertyResponse"
message="wsrf-rpw:GetResourcePropertyResponse"
wsa:Action="http://docs.oasis-open.org/wsrf/rpw-2/GetResourceProperty/
GetResourcePropertyResponse"/>
<wsdl:fault name="ResourceUnknownFault"
message="wsrf-rw:ResourceUnknownFault"/>
<wsdl:fault name="InvalidResourcePropertyQNameFault"
message="wsrf-rpw:InvalidResourcePropertyQNameFault" />
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>