c# WebService Question

I m creating a webservice and which will be accesses by more than one users, might be at the same time. To be more specifc, its a webservice related to money transactions, and as many as 1000 transactions can occur at the same time. And in order to complete the transaction the process has to go thru a number of steps. So, lets say user1 is on step 3, user 2 is on step 2  and user 3 is on the step 4. Will the correct state for all the transcations will be handled by the webservice, like maintaining a session or something once a user is connected to the webservice?

Another question is, suppose in the middle of a transaction, connection is lost, is there any way that the webservice can resume the state if the timeout hasnt been expried?

 Thanx in advance.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

In a scenario like this you will have to use transaction explicitly, either via COM+ or the Transaction class of the .NET framework.  You will have to start a transaction for each user.  I am not sure how maintaining a session will help you.  You just need to be sure that it is all or nothing.

If connection is lost the transaction will be rolled back, no change will occur to your data.  If user comes back you start from fresh.  In a scenario like this where monoey is involved ;-) you don't want to hold state
also, the calling application can call your web service asynchronously, but that won't handle the transaction portion... just another way to call a long running web service.
jyotishbAuthor Commented:
yes, i know, thats why i said timeout.  does HttpsessionState class can help me here???
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

asmx web services do not support a lot of the WS-* specs such as reliable message and transactional messaging.
asmx is also stateless and i would STAY away from session state as the answer to your problem.  there are technologies on the horizon that will do these things out of the box (Indigo/Windows Communcation Foundation). but we are in the now so i would say your architecture should go something like this.

expose an asmx web service as your endpoint.  make use of MSMQ because it will provide you with the asynchronous/ synchronous transactions, long running trans, if a connection goes down messages will wait until is back up to process.  

now here comes the harder part.

you need a service that listens to the MSMQ for messages and constructs whatever "process" you need.  This can be a windows service.

keep these things in mind.  focus on contract when working with web services.  you should possibly design your xml schema first and then gen wsdl off of that.  keep your services autonomous.  make calls chunky!!!
if your considering 1000 calls over the wire for a single transaction then i would rethink your approach.  the most expensive part of the call is the serialization so make calls chunky.

jyotishbAuthor Commented:
I m just curious abt this, cos i dont have a very deep idea abt the working of MSMQ. No there wont be 1000 calls for a single transaction. 100 transaction can occur at the same time, which will request some information to the web service.  Dont u think using MSMQ will slow the process, cos if there are say 100 transactions already waiting int he que, the next the person tryng to do the next transaction has to wait till all the others are done. I just want to know, how multiple requests at the same time are handled by webservice. Does the WS creates a session for each request?
This is very nice article with source code
plz read it and hope it will be helpful to use in your progress



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It depends, MSMQ may even speed up your service significantly.

Reason: By default asp.net will service 25 page requests at a time.  Depending on how long those transactions take to complete the httpruntime will queue the 26th user until a worker thread becomes available to handle the incoming request.  Using MSMQ your simply using web service as an endpoint so you can drop off your message and go.  The client interaction is very quick.

What things really depend on here is what you consider "a trasaction."  If you consider a transaction to be the execution of 3 stored procs then use the transaction capabilities in ado.net and forget msmq.  however if your transaction is a multistep/long running/statefull transaction then msmq is your way to go because a service can listen to the queue and only execute this "transaction" when it sees the information it needs.  Also if the server crashes or boots messages aren't loss.  Your not going to get state management like that in asp.net unless you use sql server session management.

Either way read up on it so you can be aware of this technology.  It is of no $ investment to you.  It even comes on your installation cd of win2k, xp ect.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.