“Chishiki” is Japanese for “knowledge.” e-chishiki.com aims to bring software developers, information security professionals, IT executives and other IT pros a rich body of knowledge in the form of articles, interviews, tutorials and technical discussions. Our contributors are among the biggest names in the Indian IT industry and include noted authors, educators and practitioners.
Weekly Programming Series - A Web Services Primer
A Web Services Primer (4/10): Asynchronous Web Services Client
Yashavant Kanetkar and Asang Dani
Understanding Approaches
Web Service API stubs in proxy class are generated auto-magically by wsdl.exe. It generates both synchronous and asynchronous flavors of each web service API. The web service implementation has no knowledge of asynchronous APIs. For example, GetRateBySymbol( ) has following forms in proxy class:
- public float GetRateBySymbol ( string from, string to )
- public float GetRateBySymbolAsync ( string from, string to , object state )
- public float GetRateBySymbolAsync ( string from, string to )
First API is the synchronous version. It sends a request to the server, waits for the response and then returns the result. Figure 1 shows how this happens.
| Figure 1 – Synchronous call to web service API |
As shown in Figure 1, call to API GetRateBySymbol( ) is routed to the proxy class on client machine. Proxy class converts this API call into XML based SOAP message envelope and passes it to the server over HTTP transport. SOAP message envelope is unmarshalled on the server and then CurrencyService’s GetRateBySymbol( ) is called. This function obtains latest currency conversion rate. Only after the rate is obtained, control returns to the client. On the client (which was waiting for the response), return values are unmarshalled from SOAP message envelope. Finally, control returns to doConversion( ).



