You can implement a stateful Web service as a WS-Resource, and
reference it by using a WS-Addressing endpoint reference. You develop WS-Resources
in the same way as ordinary Web services, and by using the same tools. However, you
must complete some additional tasks, as described in this topic.
About this task
Complete this task when you want to create a WS-Resource, which
is a combination of a stateful resource and a Web service through which the
resource is accessed. To complete this task you must have knowledge of standard
Web services development tasks, and the Web Services Resource Framework (WSRF)
specifications. For an introduction to the WSRF specifications, read the OASIS
WSRF Primer document.
Procedure
- Identify or create the resource component for which the WS-Resource
provides access. This resource component can either be an existing
system or entity, or a new component. You have no constraints on how you implement
the resource; it can be a simple Java™ class, a stateless session enterprise
bean, an entity bean backed by a relational database, a Service Data Object
(SDO), a Java connector, or any other component.
- Identify or create a resource properties schema document for the
WS-Resource. Use IBM® Rational® Application Developer for WebSphere®,
or any XML schema authoring tool, to create an XML schema. The schema defines
the XML complexType element for the root element of the resource properties
document.
- Create or generate a WSDL document for the Web service component
of the WS-Resource. See Developing a WSDL file for JAX-RPC applications for
information about creating WSDL files.
- Edit the WSDL file to add a ResourceProperties attribute to the
portType element. This attribute identifies the root element of the resource
properties document that you created earlier. For example, if
a Printer service has a resource properties document with a root element <printer_properties>
in the namespace http://example.org/printer, then the wsdl:portType element
might look as follows:
<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">
- Provide a means to obtain an EndpointReference that points to the
WS-Resource. You might define a wsdl:operation element called
Create that returns a wsdl:output message of type EndpointReferenceType. See Example: Creating a Web service that uses the Web Services Addressing API to access a Web Services Resource (WS-Resource) instance for an example of a CreatePrinter operation
that returns an EndpointReference object for a Printer WS-Resource.
- Define each WSRF-defined operation that the WS-Resource supports
as a child element of the wsdl:portType element. For each WSRF-defined
operation that is supported by the port type, specify the WS-Addressing action attribute on each wsdl:message element.
For example, the GetResourceProperty operation is defined in the
WSDL as follows:
<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>
The wsaw:Action attribute ensures that the WSRF-defined wsaw:Action
URIs are used for the WSRF-defined messages, rather than default URI values. Note: The
WS-ResourceProperties specification requires the presence of the GetResourceProperty
operation if the ResourceProperties attribute is present on the PortType element.
- Follow the instructions from step 2 in Creating a JAX-RPC Web service application that uses Web Services Addressing to create the implementation of the WS-Resource, enable
the client to access the WS-Resource by using an endpoint reference, and deploy
the application.