Announcement Announcement Module
No announcement yet.
consuming web services within a transaction Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • consuming web services within a transaction

    Say I have an application that has a database that stores data, but I also update a legacy system via a web service. My first question, for people who have architected solutions like this, do you create a DAO layer for the web services that you are consuming? If so, does spring have/need a WebServicesDaoSupport that you can extend to make dealing with web services easier? My main question though is about transactions. Is there any way to design a web service that can participate in a transaction? So for example, say I have an object which I have to update in my legacy system as well as the database. Imagine I have a business layer manager with a method like this:

    public void save(Object obj) {;;
    Is there any easy way to design this so that if there is an exception thrown during that the changes made during are somehow rolled back?

  • #2

    I think there is some specification on transaction propagation over web services. If this spec is implemented and your legacy web services use it, then you're lucky.

    Otherwise, just structure your code like this:
        //tx start;;;
      //tx end
    By this I mean you should structure your code so that the databaseDao calls occur in the first part of the transaction and the legacyDao calls in the second part of the transaction. Also, if you are using Hibernate or something simmillar be carefull that the hibernateSession.flush() is called in you databaseDao methods. Otherwise, the hibernateSession.flush() would be done automatically at the and of the transaction, after the calls to legacyDao.