Click here to Skip to main content
15,894,955 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
HI is there any mechanism which can handle situation like this

''' if i have one web service with 3 methods in it say
UpdateTbl,InsertTbl,DeleteTbl web methods

if i am calling these methods from client To Run them

like this
First UpdateTbl method which performs some operation in database
Second InsertTbl method which performs some operation on same database of above
Third DeleteTbl method which performs some operation on same database of Above


now can i set at client side that
iF any of the above method fails with exception i should get all my database operations to rollback to state which was before calling first method ??


please help us with your valuable suggestions
Posted

1 solution

A webservice is stateless and therefore not well suited to handle such things from the client side. The webservice can hold a session state which you might use for that, but this still would be a hack.

The real problem is, that the client side (which is the presentation layer) should not have any knowledge or control over transactions on the server (the application logic). This is a question of proper application design and when a layer (in this case the client) needs to know about another layer's internal state, then there is something wrong with the design.

Let's assume you have the following methods:

GetUser(), UpdateUser(), UpdateActiveUserList()

You might call them whenever a user logs in, but three separate calls would not be in a transaction. So why don't you implement a new web method UserLogin() which internally uses all three methods in a transaction? Then the server 'knows' how to handle this and the client must not care about details like transactons anymore. And, of course, expose only those methods as web methods which the client really needs, no more and no less.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900