I am trying to develop a web service that is invoked using Javascript and SOAP. It is a stateful service that users can log in to for certain time, and as such I use Context.Session to store necessary data. Users invoke a lengthy operation (after logging in) and need to receive regular status updates. The problem that I have is that my service behaves in a way that only one call can be executed at a time (i.e. WebMethod A()) and I cannot invoke WebMethod B() until A() finished executing. There are two questions: What is the best approach for receiving status updates - can server postback the data to the client automatically or is it best to poll GetStatus service method instead? How can I achieve async. execution INSIDE the web service so that I can call different and sometimes totally unrelated web methods from same web service? Thanks!
Asked
Active
Viewed 228 times
0
-
I am not sure why do you say that you can't call Method B until Method A is finished. You shouldn't have any problem executing both methods almost concurrently if you call them from Javascript. I will post a "rough" idea on how to do it. – Icarus Sep 08 '11 at 04:27
1 Answers
0
Using JQuery you could do this:
function CallMethodA() {
$.ajax({
type: "POST",
url: "WebService.asmx/MethodA",
// whatever else ...
success: function (response) {
//handle success
}
});
CallMethodB();
}
function CallMethodB() {
$.ajax({
type: "POST",
url: "WebService.asmx/MethodB",
// whatever else ...
success: function (response) {
//handle success
}
});
}

Icarus
- 63,293
- 14
- 100
- 115
-
Thanks Icarus, that's the way I do it anyway. Looks like I will have to check server config, because apparenty App Pool under which I run web service under has "Maximum number of worker processes" set to 1. That shouldn't prevent me from spawning child threads, should it? – Daniel Protopopov Sep 08 '11 at 04:53
-
I suppose it has already been covered by http://stackoverflow.com/questions/860478/asp-net-mvc-jquery-iis6-multiple-ajax-requests. You can submit multiple requests to the server but they are going to be processed sequentially. – Daniel Protopopov Sep 08 '11 at 23:49
-
@Acolyte I don't think so. You can definitely send several requests to the server and they will be processed in parallel. Yes, there's a limit (I believe the "standard" is four) but that limit is definitely not one unless there's some sort of special config on the server or the client side. The easiest thing to prove what I'm saying is by firing up firebug and seeing how many requests are processed in parallel for the same domain for any given web site. – Icarus Sep 09 '11 at 00:07
-
It's not so much the client that I'm concerned about, but the server. We've got an old IIS6 on W2K3 and I suspect that there is something preventing it from creating threads in the first place. – Daniel Protopopov Sep 09 '11 at 02:31
-
1@Acolyte: that may very well be the case. The server can limit the number of concurrent connections coming from the same IP. I've seen this setting in Apache and I'm sure IIS can do the same thing. – Icarus Sep 09 '11 at 02:38