locked
Ask about Web Service response work with transaction RRS feed

  • Question

  • User1032445712 posted

    Hi all,

    I have a requirement below;

    Step 1: I must insert and update record with "xx" Running Number into Tables in Database.

    Step 2: I must send "xx" Running Number from Step 1 go with Web Service and wait the response.

    Step 3: If Step 2 has a error. I must roll back Step 1 data that I do in Step 1. But If Step 2 is success, everything is Ok.

     

    How can I solve this requirement? and How can I write asp.net code?

     

    Thank you very much

    Saturday, March 20, 2010 7:24 PM

Answers

  • User-525215917 posted

    What is the requirement? Do you have to rollback all inserts and updates when at least some Step 2 has error or only the erroneous Step 2? How looks the response you get from web service?

    Basically, your code should follow this algorithm, by example:

    1. Open database connection
    2. Iterate through rows you must insert or update
    3. For each row begin transaction
    4. Insert or update the row
    5. Send data to web service and get response from it
    6. If response is OK then commit transaction
    7. If response is not OK then rollback transaction
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 21, 2010 4:53 AM

All replies

  • User1408790675 posted

    i'm not sure what is your requirement right now, but i would suggest you avoid this chatty calls to the web services. going back to your requirement, its better if you have your webservice method return a status say an struct status that represents the success/failure and the message of the status. more like a: public ServiceStatus UpdateRunningTotal() {...return serviceStatus;}

    Sunday, March 21, 2010 12:23 AM
  • User-525215917 posted

    What is the requirement? Do you have to rollback all inserts and updates when at least some Step 2 has error or only the erroneous Step 2? How looks the response you get from web service?

    Basically, your code should follow this algorithm, by example:

    1. Open database connection
    2. Iterate through rows you must insert or update
    3. For each row begin transaction
    4. Insert or update the row
    5. Send data to web service and get response from it
    6. If response is OK then commit transaction
    7. If response is not OK then rollback transaction
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 21, 2010 4:53 AM
  • User-952121411 posted

    To make a further reccomendation, if you do indeed need to make some chatty calls as part of the requirment (if it is unavoidable), you might consider using a WCF service with a TcpBinding if possible as opposed to an XML web service call that will be much slower.  In all actuality even a basicHttpBinding in WCF will have better performance that a traditional .asmx web service.

    Choosing a Communication Technology:

    http://geekswithblogs.net/claraoscura/archive/2007/05/28/112799.aspx

    Choosing a Transport:

    http://msdn.microsoft.com/en-us/library/ms733769.aspx

     

     

    Tuesday, March 23, 2010 3:49 PM