Wednesday, May 14, 2008

Web Services Running Asynchronously?

On and off over the last few days, I've been attempting to find ways to let a web method request wait for completion of a few tasks before returning a result to the browser. There are several cases where a thread from the thread pool can be on-hold or blocking while nothing is happening. In away, what I've been looking for is event-driven web services.

For example, when a Web Service (MyWebService) is attempting to access an external web service (TheirWebService) MyWebService will continue to hang onto a thread while TheirWebService is pending completion. To return resources to the thread pool, a developer can make use of server-side asynchronous web methods. I found an article on MSDN from Matt Powell (of course it's very old) that outlines how to do it. My results where mixed however. When I used an ASMX accessed via AJAX web service calls, the call continued to be returned and the javascript always got back the IAsyncResult.

For my test, the ASMX file was in the same project as the ASPX/AJAX page. I'm not exactly certain why the result was always returned, but I believe Visual Studio does some funky inspection of methods and builds a js proxy to call those methods. At any rate, I believe this method will assist in future efforts (like implementing an event-driven server-side push methodology). But thus far, it remains only cool in concept.

3 comments:

Anonymous said...

Dear Author www.chadcoley.com !
Yes well!

Unknown said...

After a few attempts, we used a different model instead. I do think asynchronous processes have potential for long running requests, but I haven't drilled in further.

Anonymous said...

I want to quote your post in my blog. It can?
And you et an account on Twitter?