Home / Articles / Programming Languages / Web Services / Asynchronous Web Services Client

“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
Yashavant Kanetkar and Asang Dani

God has blessed human beings with the ability to perform several tasks concurrently. That is why we are able to drive a car, listen to music, follow the traffic rules, talk to the co-passengers—all this without losing the mains focus, i.e. driving. Since programmers are human beings and programming is the art of solving people’s problems, it is only natural that programmers have evolved mechanisms to perform several activities concurrently. Opportunities for the use parallelism of exists quite naturally in Web Service applications. In this article we will try to elaborate upon this theme.

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:

  1. public float GetRateBySymbol ( string from, string to )
  2. public float GetRateBySymbolAsync ( string from, string to , object state )
  3. 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( ).

Comments

Log in or create a user account to comment.

On Sale From April 2008

Let Us C
8th Ed.
C programming classic & best seller. 1 million+ copies sold!

Y. Kanetkar

On Sale From April 2008

Introduction to Object Oriented Programming & C++

Y. Kanetkar

On Sale From Fall 2008

Microsoft .NET Framework: Web Application Security

Vijay Mukhi

On Sale From Nolvember 2008

Quest C++ Courseware
12+ hours of instructional audio and animated slides.

Y. Kanetkar Asang Dani

On Sale From November 2008

A Programmer's Guide to Web Application Security

Vijay Mukhi

Latest Forum Posts