웹 서비스 자원 프레임워크를 사용하여 Stateful 웹 서비스 작성
Stateful 웹 서비스를 WS-Resource로 구현하고 WS-Addressing 엔드포인트 참조를 사용하여 이 서비스를 참조할 수 있습니다. WS-Resources를 일반적인 웹 서비스와 같은 방법으로 개발하거나 같은 도구를 사용하여 개발합니다. 그러나 이 주제에서 설명한 대로 몇몇 추가 태스크를 완료해야 합니다.
이 태스크 정보
Stateful 자원과 자원에 액세스하는 데 사용되는 웹 서비스의 조합인 WS-Resource를 작성하려면 이 태스크를 완료하십시오. 이 태스크를 완료하려면 표준 웹 서비스 개발 태스크 및 WSRF(Web Services Resource Framework) 스펙에 대한 지식이 있어야 합니다. WSRF 스펙에 대한 소개는 OASIS WSRF Primer 문서를 읽으십시오.
프로시저
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를 사용하는 경우 표준화된 웹 서비스 메시지를 사용하여 자원의 상태 표시와 상호작용하는 상호 운용 가능한 수단을 제공합니다.
<?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>