Application Modernization: What Is It and How to Get Started
When designing applications for consuming Web services, the response time needs to be taken into consideration. If the Web service happens to be on a remote server in an Internet scenario, the response times could be quite high due to heavy network traffic. Or, if the function call itself takes some time to return the response due to heavy processing involved, the response time would be high. A well-designed client application should not wait for the response for so long. It should manage its Web method calls efficiently, especially when there are multiple calls.
The ASP.NET Framework does provide support for accessing a Web service asynchronously. The user can wait until the request completes, can block on the WaitHandle, or wait for a callback function to be invoked. However, WSE 2.0 provides a potentially more powerful way of communicating with a Web service by using WS Addressing. In this white paper, you will see an approach to efficiently communicate with a Web service asynchronously.
ASP.NET Web Services Using HTTPHandler
The HTTPHandler object is called by the HTTPApplication object whenever a request or response comes in or out of an ASP.NET Web page. The Handler is registered in the application configuration file. Once it is registered, every time a request comes for the specified ashx file, the code in the HTTPHandler is executed.
Here is a sample snippet of code for registering the HTTPHandler:
<httpHandlers> <add type="AsyncWebClient.AsynReceiver, AsyncWebClient" path=" *.ashx" verb="*" /> </httpHandlers>
The code in AsynReceiver class can be tuned to handle the request/response for the Web page.