WebSphere Application Server for i5/OS, Version 6.1   
             オペレーティング・システム: i5/OS

             目次と検索結果のパーソナライズ化

例: Web Services Addressing API を使用して Web Services Resource (WS-Resource) インスタンスをアクセスする Web サービスの作成

この例は、「Web Services Addressing API を使用して汎用 Web サービス・リソース・インスタンスをアクセスする Web サービスの作成」の例を拡張して、WS-Resource を使用します。WS-Resource は、定義により、リソースと Web サービス (リソースはこれを使用してアクセスされます) の組み合わせです。

WS-Resource 用リソース・プロパティー・スキーマ文書の作成

Web Services Resource Framework (WSRF) 仕様の一部である WS-Resource 仕様で記述されているように、WS-Resource へのアクセスは、WS-Addressing エンドポイント参照で行われ、 そのリソースの状態の表示内容は、リソース・プロパティー XML 文書で維持されます。 ステートフル・リソースを表記するための WS-Resource の使用によって、 標準化された Web サービス・メッセージを使用して、リソースの状態表記と対話する相互作用手法が提供されます。

WS-Resource には、XML スキーマで記述されたリソース・プロパティー XML 文書が必要です。 この文書は、WS-Resource の状態を特定の視点から記述するものです。 プリンターの WS-Resource スキーマ文書は、以下の例のようになります。
<?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>

WS-Resource の Web サービス・コンポーネント用 WSDL 定義の作成および編集

Printer WS-Resource サーバーの WSDL 定義は、例: Web Services Addressing API を使用して汎用 Web サービス・リソース・インスタンスにアクセスする Web サービスの作成 の場合と同じでが、wsdlPortType エレメントに関する ResourceProperties 属性が加わっています。 汎用 Web サービスではなく、WS-Resource によってポート・タイプを実装することを、 この属性によって宣言します。 リソース・プロパティー文書タイプ宣言が、 インターフェースに含まれているため、 このインターフェースには、WSRF 定義の GetResourceProperty オペレーションも含める必要があります。 このオペレーションは、WS-ResourceProperties 仕様で必須のものとなっています。
<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>

WS-Resource の Web サービス・コンポーネントのインプリメント

Web サービスは、例: Web Services Addressing API を使用して汎用 Web サービス・リソース・インスタンスにアクセスする Web サービスの作成 の説明にあるとおり、 通常の Web サービスと同様にインプリメントします。 この例では、汎用 Web サービス・リソース・インスタンスを参照するエンドポイント参照の使用方法について説明します。WS-Resource インスタンスは、WSRF 仕様で定義されている標準化されたメッセージ交換をサポートする、 リソース・インスタンス固有のタイプです。




関連概念
Web Services Resource Framework サポート
関連タスク
Web サービス・リソース・フレームワークを使用したステートフル Web サービスの作成
関連資料
例: Web Services Addressing API を使用して汎用 Web サービス・リソース・インスタンスにアクセスする Web サービスの作成
Web Services Addressing API
Web Services Addressing SPI
参照トピック    

ご利用条件 | フィードバック

最終更新: Jan 21, 2008 5:46:14 PM EST
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.base.iseries.doc/info/iseries/ae/xwbs_wsrf.html