File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes webservice and distributed tx Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "webservice and distributed tx" Watch "webservice and distributed tx" New topic

webservice and distributed tx

satish bodas
Ranch Hand

Joined: Jun 19, 2008
Posts: 116
Hello ,
I am new to web services and have a question ::

Scenario ::
Need to invoke a web service that would store some information in db
also would need to myself write some data to a local db

So essentially have to perform two operations
will be using a sateless session bean ( ejb 3.0 )

If the order of operations is ::
1 >invoke web service
2 >write to local db

If there are errors while I try and write to local db - can the data in web service be reversed ?

one solution could be first write to local db .....

However I want to first invole web service

Thanks ,
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
WS by themselves have no notion of being part of a transaction, so you'd need to call some other WS operation to undo the DB operation if the TX fails later.

The BPEL standard (which can orchestrate several WS calls into a single one) has the notion of "compensating actions" which could be used for this. But using BPEL just for this would mean a nontrivial amount of overhead, and wouldn't be a good fit to begin with if parts of the operation happen locally.
arulk pillai
Ranch Hand

Joined: May 31, 2007
Posts: 3371
If the DB operation succeeds make a WS Call. If the WS call fails roll back the DB operation.

[] | [Java job hunting know how] | [Java resumes]
I agree. Here's the link:
subject: webservice and distributed tx
It's not a secret anymore!