“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 (2/10): Consume It, Your Majesty
Yashavant Kanetkar and Asang Dani
Getting Ready to Use a Web Service
To use Web Services through the .NET platform, we need one of the following tools:
- Visual Studio 2005 Professional
- Visual Studio 2005 Express Editions (C# or VB.NET)
Once we have installed one of these tools on our system, we can start exploring Web Services right away. The first question that comes to mind is - where is the web service that I wish to use, located? Well, where else but on the network. To be able to access a web service, we must either know the URL where it is located or we must be able to discover it. As you can guess, the first method is simpler. Hence, for this article we will use the first way. We have created one such web service called CurrencyService. It is located at:
http://quest.ksetindia.com/services/CurrencyService/
Open your web browser and type this URL in the address bar. On doing so, the following output will appear.
Figure 1 – Locating a web service
At the outset, we are shown a list of supported operations also called APIs (Application Programmer's Interfaces). Clicking on any of the operations like GetCountryNames, shows the following output:
Figure 2 – Exploring Operations in a web service
By now you must be wondering - "is this is how we use a web service?" The answer is a definite no. This simply gives you some idea about the web service. It is not enough to start using the web service in our program. To use the web service in our program, we need its description in XML format. This description is as per a standard called WSDL (Web Service Description Language). The easiest way to get this description is to click on the "Service Description" link given on the front-page of CurrencyService. When you click on this link, it produces the following output.
Figure 3 – WSDL for CurrencyService web service
If you casually glance through the output, you will notice that it contains a description of:
- Each operation supported by the web service
- Parameters for each operation
- Return type if any
http://www.w3.org/TR/wsdl: This is all that we need to know about WSDL! If you are interested, you can visit and soak yourself in the details of the WSDL specification. In our opinion, this is not required just as yet. From now on, using CurrencyWebService mentioned above, would simply require you to refer to this URL:
http://quest.ksetindia.com/services/CurrencyService/CurrencyService.asmx?WSDL
Let us now create a simple WinForm application to access this web service.




I always get the value as -1
Abhishek Srivastava
June 12, 2008