Aruna,
There is a way to use transactions in a web service. Since it is stateless,
you must keep track of the user who made the request. You may want to have a
collection of "ActiveUsers" which is going to have as part of its fields
userId and connection. Whenever you start a transaction you can return a
unique Id. You must provide that Id whenever you make another request to the
web service (Update, Insert, Delete). The web service is going to loop throw
the collection and find the user with the specified Id. Once the user is
found, you can grab the connection and pass it to the Update, Insert or
Delete methods so that the connection doesnt get closed.
Then you can call the Comit or Rollback.
Gilberto
connections/transactions between web service calls - this is very
inefficient and can cause many problems when clients will be making
concurrent calls to your web service.
Better think how to make your web service stateless.
"Rafal Gwizdala" wrote:
erymuzuan wrote: One way is you can utilise ASP.Net Session state framework to achieve
this. or you can create a singleton remoting object on the server.
regards
erymuzuan mustapa
Sniper wrote:
Hi guys
I have facing a small problem, it's like this.
There is a web service which has a web method call
OpenPublicConnection which will open a connection to the SQL Server,
and there is a web method call StartTransaction to start a tranaction
for the class level connection which is opened by the
OpenPublicConection Method. But when I call StartTransaction it's
retruing an error saing the connection is closed... ? Is there anyway
to fix this?? is there anyway to keep the conneciton object alive in
the server side till client call the StartTransaction Method after
calling the OpenPublicConnection method...?
Thanks for your help
-Aruna
You could try to solve this problem, but I think the problem is in your
web service design. You should not leave open database
connections/transactions between web service calls - this is very
inefficient and can cause many problems when clients will be making
concurrent calls to your web service.
Better think how to make your web service stateless.
Best regards
Rafal Gwizdala