As mentioned previously in this chapter, in the section on “Proxy Class Details,” web services allow the developer to call any of the exposed web methods either synchronously or asynchronously.
Figure 16-6. StockTickerConsumer in action
When a method is called synchronously, which is the “normal” way of doing method calls, the program execution waits for the method to return. As long as the method does not take too long to process and there is not too much network delay, this pause will not be a problem.
Figure 16-7 shows synchronous processing . Methods are called on the server via the proxy. The calling program is unaware a proxy is intervening in the process. A call goes out and when the results come back, the calling program continues processing.
Figure 16-7. Synchronous method calls
However, in situations where the method is time-consuming to process (for example, a lengthy database operation or extensive computation) or where the network delay is significant, then this delay can be an unacceptable performance hit. In the case of web services, where all the method calls entail a round trip over the Internet, long network delays are common. Broadband Internet connections can help, but performance will still suffer.
One solution is to use asynchronous processing. ...