+

Search Tips   |   Advanced Search

Create stateful Web services using the Web Services Resource Framework


We can implement a stateful Web service as a WS-Resource, and reference it using a WS-Addressing endpoint reference. You develop WS-Resources in the same way as ordinary Web services using the same tools, however, perform some additional tasks, as described in this topic.

Perform 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 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.

 

  1. 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. we 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.

  2. 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.

  3. Create or generate a WSDL document for the Web service component of the WS-Resource. See Develop a WSDL file for JAX-RPC applications for information about creating WSDL files.

  4. Edit the WSDL file to add a ResourceProperties attribute to the portType element. This attribute identifies the root element of the resource properties document createdd 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">
    
    

  5. Provide a means to obtain an EndpointReference that points to the WS-Resource. We 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.

  6. 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.

    The WS-ResourceProperties spec requires the presence of the GetResourceProperty operation if the ResourceProperties attribute is present on the PortType element.

  7. Follow the instructions from step 2 in Create 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 using an endpoint reference, and deploy the application.

 

Next steps

Review Example: Creating a Web service that uses the Web Services Addressing API to access a Web Services Resource (WS-Resource) instance for sample WS-Resource code.


Web Services Resource Framework support
Web Services Resource Framework resource property and lifecycle operations
Example: Creating a Web service that uses the Web Services Addressing API to access a Web Services Resource (WS-Resource) instance

 

Related concepts


Web Services Addressing support

 

Related tasks


Create a JAX-RPC Web service application that uses Web Services Addressing
Task overview: Implement Web services applications

 

Related


WSDL2Java command for JAX-RPC applications
Java 2WSDL command for JAX-RPC applications

 

Related information


Web Services Addressing application model OASIS WSRF primer