웹 서비스 자원 프레임워크를 사용하여 Stateful 웹 서비스 작성

Stateful 웹 서비스를 WS-Resource로 구현하고 WS-Addressing 엔드포인트 참조를 사용하여 이 서비스를 참조할 수 있습니다. WS-Resources를 일반적인 웹 서비스와 같은 방법으로 개발하거나 같은 도구를 사용하여 개발합니다. 그러나 이 주제에서 설명한 대로 몇몇 추가 태스크를 완료해야 합니다.

이 태스크 정보

Stateful 자원과 자원에 액세스하는 데 사용되는 웹 서비스의 조합인 WS-Resource를 작성하려면 이 태스크를 완료하십시오. 이 태스크를 완료하려면 표준 웹 서비스 개발 태스크 및 WSRF(Web Services Resource Framework) 스펙에 대한 지식이 있어야 합니다. WSRF 스펙에 대한 소개는 OASIS WSRF Primer 문서를 읽으십시오.

프로시저

  1. WS-Resource가 액세스를 제공하는 자원 컴포넌트를 식별하거나 작성하십시오. 이 자원 컴포넌트는 기존 시스템 또는 엔티티이거나 새 컴포넌트일 수 있습니다. 자원을 구현하는 방법에는 제한조건이 없습니다. 이는 단순 Java™ 클래스, Stateless 세션 엔터프라이즈 Bean, 관계형 데이터베이스의 지원을 받는 엔티티 Bean, 서비스 데이터 오브젝트(SDO), Java 커넥터 또는 다른 컴포넌트일 수 있습니다.
  2. WS-Resource의 자원 특성 스키마 문서를 식별하거나 작성하십시오. IBM® Rational® Application Developer for WebSphere® 또는 XML 스키마 작성자 도구를 사용하여 XML 스키마를 작성하십시오. 스키마는 자원 특성 문서의 루트 요소에 대한 XML complexType 요소를 정의합니다.
  3. WS-Resource의 웹 서비스 컴포넌트에 대한 WSDL 문서를 작성하거나 생성하십시오. WSDL 파일 작성에 대한 정보는 JAX-RPC 애플리케이션에 대한 WSDL 파일 개발의 내용을 참조하십시오.
  4. WSDL 파일을 편집하여 ResourceProperties 속성을 portType 요소에 추가하십시오. 이 속성은 이전에 작성한 자원 특성 문서의 루트 요소를 식별합니다. 예를 들어, Printer 서비스에서 네임스페이스 http://example.org/printer에 루트 요소 <printer_properties>가 있는 자원 특성 문서가 있으면 wsdl:portType 요소는 다음과 같습니다.
    <wsdl:portType xmlns:pr="http://example.org/printer"  
                   xmlns:wsrf-rp="http://docs.oasis-open.org/wsrf/rp-2"
                   name="Printer" wsrf-rp:ResourceProperties="pr:printer_properties">
  5. WS-Resource를 가리키는 EndpointReference를 얻기 위한 수단을 제공하십시오. EndpointReferenceType의 wsdl:output 메시지를 리턴하는 Create라는 wsdl:operation 요소를 정의할 수도 있습니다. Printer WS-Resource에 대한 EndpointReference 오브젝트를 리턴하는 CreatePrinter 조작 예제를 참조하십시오.
  6. wsdl:portType 요소의 하위 요소로 WS-Resource가 지원하는 각 WSRF 정의 조작을 정의하십시오. 포트 유형이 지원하는 각 WSRF 정의 조작의 경우, 각 wsdl:message 요소에서 WS-Addressing action 속성을 지정하십시오. 예를 들어, GetResourceProperty 조작은 WSDL에 다음과 같이 정의되어 있습니다.
    <wsdl:operation name="GetResourceProperty" 
                    xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" 
                    xmlns:wsrf-rpw="http://docs.oasis-open.org/wsrf/rpw-2">
      <wsdl:input name="GetResourcePropertyRequest" message="wsrf-rpw:GetResourcePropertyRequest"
        wsaw:Action="http://docs.oasis-open.org/wsrf/rpw-2/GetResourceProperty/GetResourcePropertyRequest"/>
      <wsdl:output name="GetResourcePropertyResponse" message="wsrf-rpw:GetResourcePropertyResponse"
        wsaw:Action="http://docs.oasis-open.org/wsrf/rpw-2/GetResourceProperty/GetResourcePropertyResponse"/>
      ...
    </wsdl:operation>
    wsaw:Action 속성은 WSRF 정의 메시지에 기본 URI 값이 아니라 WSRF 정의 wsaw:Action URI가 사용되도록 합니다.
    참고: ResourceProperties 속성이 PortType 요소에 있는 경우 WS-ResourceProperties 스펙에는 GetResourceProperty 조작이 있어야 합니다.
  7. 웹 서비스 주소 지정을 사용하는 JAX-RPC 웹 서비스 애플리케이션 작성에서 2단계의 지시사항에 따라 WS-Resource의 구현을 작성하여 클라이언트가 엔드포인트 참조를 사용하여 WS-Resource에 액세스할 수 있도록 하고 애플리케이션을 배치하십시오.

WS-Resource의 자원 특성 스키마 문서 작성

다음 예제는 프로시저에서 2 - 4단계에 해당합니다. 예제에서는 IT 조직에서 프린터 네트워크를 관리하기 위해 WS-Resource 인스턴스를 사용할 수 있는 방법을 보여줍니다. WS-Resource는 자원 및 자원에 액세스할 때 사용하는 웹 서비스의 조합입니다. 예제에서는 웹 서비스 주소 지정을 사용하는 JAX-RPC 웹 서비스 애플리케이션 작성의 예제에서 설정한 대로 해당 프린터 네트워크를 관리하기 위해 조직이 현재 웹 서비스를 사용한다고 가정합니다.

WSRF(Web Services Resource Framework) 스펙의 일부인 WS-Resource 스펙에서 설명된 대로 WS-Resource는 WS-Addressing 엔드포인트 참조를 통해 액세스하며, 자원 상태에 대한 보기는 자원 특성 XML 문서에서 유지보수됩니다. Stateful 자원의 표시를 위해 WS-Resource를 사용하는 경우 표준화된 웹 서비스 메시지를 사용하여 자원의 상태 표시와 상호작용하는 상호 운용 가능한 수단을 제공합니다.

WS-Resource에는 WS-Resource 상태의 특정 보기를 설명하는 XML 스키마로 설명된 자원 특성 XML 문서가 있어야 합니다. 프린터 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 서버의 WSDL 정의는 wsdlPortType 요소에 ResourceProperties 속성을 추가한 상태의 WS-Addressing 예제와 동일합니다. 이 속성은 포트 유형이 일반 웹 서비스가 아닌 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>

주제 유형을 표시하는 아이콘 태스크 주제



시간소인 아이콘 마지막 업데이트 날짜: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=twbs_wsrf
파일 이름:twbs_wsrf.html