Home / Articles / Programming Languages / Web Services / A Web Services Primer (2/10): Consume It, Your Majesty

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

Index

  1. Getting Ready to Use a Web Service
  2. Using the Currency Web Service
  3. Event Handlers
Paid or free, small or big, secure or insecure, scalable or otherwise, .NET based or Java based …. all Web Services serve one single minded purpose… letting the viewer, look at the world. They throw open a world, which is yours for the taking, we are sure that by the time you reach end of this series, you would get more than a glimpse of their power and utility.

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:

  1. Each operation supported by the web service
  2. Parameters for each operation
  3. 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.

Comments

I always get the value as -1

I always get the value of converted currency as -1 even when converting Rupee to Rupee. Is there anything wrong with the method returning values??

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