I had always known about webservices and a few of the hundred thousand acronyms associated with the webservices ecosystem, but I had never really written code to use them. I avoided working with them because, I don’t know why, I always thought of them what any protester thinks of a Government. Ok, I just said I don’t know why I thought that way so you are free to assume your reasons, and most of them, I fear, would be right. But it was just a matter of time before I could not avoid working with webservices any longer and was about to get to know them for real. They are far from anything as boring and clunky as Governments across our planet. On the contrary, they are a easy and powerful and even quite fun. And now that I dont hate and avoid webservices anymore, I must share what good things I know about them.
I am a sucker for simplifying all things, especially stuff related to technology, except when I am in mood for some geekism :-) So dont be surprised if the answers and information you find here sounds different (read:layman-ish) from what you are used to find most other places.
What is a webservice?
A webservice is any piece of software, that provides some functionality, is available over the internet, and talks using standardized XML.
The ‘standardized’ part in the answer above makes webservices seemingly boring, but that is so only when you have got a wrong perspective of things. Standardization here has immense benefits and is what makes webservices such a neat idea. Let me show you how -
Let ‘you’ = you OR any application OR just a piece of code OR something else. Now..
You can talk to a webservice over the network via HTTP, SMTP, FTP, BEEP and many other protocols.
When you talk to a webservice, the ‘talk’ part is done using XML in a standardized fashion. The current standardized fashion being XML-RPC and SOAP.
All stuff that a webservice would do for you (functionality provided) and all things it would need from you to do so (expected input) is described in XML in a standardized way called WSDL.
Webservices live in registries in a way such that the right one for the job can be very easily found. This is made possible by another standardized XML way called UDDI.
XML is the music which makes webservices dance
All these pointers above are the real fundamental ideas associated with webservices, but of course I would encourage you to learn more things and in detail -
Best FAQ I could find on webservices - http://www.webservicex.net/WS/faq.aspx
A blessing of an article demystifying acronyms associated with webservices and more -http://www.xml.com/lpt/a/888
Getting started with webservices - a hands on
Say we are in need of fetching stock quotes of a publicly traded company and use the data in some in our application. We could serach for webservices that allow us to do just that on public webservice repositories such as http://www.service-repository.com/ andhttp://www.webservicex.net/WS/wscatlist.aspx. Or you could request access to use paid webservices, for example Reuters has a very comprehensive paid webservice that provides all imaginable functionality related to stock and financial markets.
Lets use the ‘stock quote’ webservice here - http://www.webservicex.net/WS/WSDetails.aspx?WSID=9&CATID=2 that is present in the later public repository. And lets get this task done using the popular HTTP::Request module for perl (this and more ways of working with webservices are covered later in this post)