Network Deployment (Distributed operating systems), v8.0 > Develop and deploying applications > Develop web services - Transaction support (WS-Transaction)


Create an application that uses the Web Services Business Activity support

To create an application component that uses the business activity support, set Run EJB methods under a Business Activity scope in the deployment descriptor of the relevant application component, and if required, create and specify a compensation handler for the application to use if there is an error. You then build the component into the application and deploy the application onto a server that has the business activity support enabled. The application component can be either an enterprise bean or a web service that is implemented as an enterprise bean.

For information about editing deployment descriptors by using Rational Application Developer, refer to the Rational Application Developer information.

Complete this task for an application that runs on a business-activity-enabled sever to use the business activity support at run time, and to undertake work that might later be compensated by a compensation handler. If the application requires compensation when a business activity scope ends, the application passes the data that is required by the compensation process to a compensation handler indirectly, by using the business activity API. The data that is required by the compensation process can be in the form of either a serializable object or a Service Data Object (SDO).


Procedure

  1. Design the application component that requires the business activity support. In particular, define the application component requirements for compensation and close activities. If the application component requires compensation, define the nature of the data in the serializable object or the SDO that the application component passes to the compensation handler.

  2. Use the information from the application design, create the compensation handler for the application component, if required. This handler defines the close and compensation logic that runs upon completion of a business activity scope that has the handler added to it through an application component.

    1. Open your chosen WAS assembly tool.

    2. Create a new Java class that implements the appropriate interface, depending on the format of the data that is required by the compensation process:

      • For a serializable object, implement the com.ibm.websphere.wsba.serializable.CompensationHandler interface.

      • For an SDO, implement the com.ibm.websphere.wsba.CompensationHandler interface.

    3. Implement the close and compensate methods on the new compensation handler object, to take appropriate actions depending on the serializable or SDO data that passes to the handler when it is invoked.

    The compensation handler class is now ready for the application component to reference, and for assembly into an application.

  3. Open the application component in the assembly tool.

  4. Open the deployment descriptor for the application component in the deployment descriptor viewer.

  5. Scroll to the Compensation section and select the Run EJB methods under a Business Activity scope check box.

  6. In the Compensation handler class text field, type the fully qualified class name of the compensation handler class that you created earlier.

  7. Save the deployment descriptor.
  8. Build the application, including both the application component and the compensation handler. If the application is a web service, the application must be compliant with the Java Specification Request (JSR) 109 standard.
  9. Deploy the application onto an application server that is business-activity-enabled.


Results

The application is now business-activity-enabled, and can use the business activity support at run time through the business activity API. The application component has a compensation handler associated with it, and can therefore call the setCompensationDataImmediate and setCompensationDataAtCommit methods at run time to add the compensation handler to the business activity scope. For more information about these methods, see the topics about the Business activity API. If the unit of work with which the business activity scope is associated fails, the compensation handler performs actions to compensate for the error.


What to do next

Ensure that the compensation handler class is on the application class path for the WAS runtime environment.
Web Services Business Activity support in the application server
Transaction compensation and business activity support
Assembly tools
Use WS-Transaction policy to coordinate transactions or business activities for web services
Configure a server to use business activity support
Use the transaction service


Related


Business activity API
SDO article on developerWorks

+

Search Tips   |   Advanced Search