c# WebService Question

Posted on 2006-04-27
Medium Priority
Last Modified: 2008-01-16
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.
Question by:jyotishb
LVL 12

Expert Comment

ID: 16554705
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

Expert Comment

ID: 16554923
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.

Author Comment

ID: 16555035
yes, i know, thats why i said timeout.  does HttpsessionState class can help me here???
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 13

Expert Comment

ID: 16555587
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.


Author Comment

ID: 16555711
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?
LVL 10

Accepted Solution

SystemExpert earned 1000 total points
ID: 16561188
This is very nice article with source code
plz read it and hope it will be helpful to use in your progress


LVL 13

Assisted Solution

devsolns earned 1000 total points
ID: 16561639
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.


Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question