File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "webservice and distributed tx" Watch "webservice and distributed tx" New topic
Author

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 ,
~satish
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42908
    
  69
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
Author
Ranch Hand

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


500+ Java Interview Questions and Answers | Java job hunting know how & Java resumes
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: webservice and distributed tx