by April 3, 2003 0 comments



To explain what Web Services are, consider the following scenario. Take a young developer, say Ramesh, working in a software development company. One of the company’s major clients has had a comprehensive intranet built for them and Ramesh was part of the team that built it.

A couple of days before the World Cup, the IT manager of the client calls up the company and tells them that they anticipate that employees working at the client’s company would be browsing to different sites to check the World Cup scores. Although they do not want to restrict this access, would it be possible to pick up the scores from any site on the Web and show it on the intranet’s home page? This would save bandwidth as well as show the employees that the company does not have restrictive policies. 

Ramesh is assigned to this task of adding a small section to the intranet’s home page that displays the current match’s scores. Ramesh does the following for this: he browses over to a few sites that display the World Cup scores. He then downloads the HTML page, views their source code and decides to pick one as the “source site” for the scores for the intranet home page.

He then writes a small component that periodically (say every 5 mins) connects to this website, downloads the specified page to the intranet server and reads the HTML in it. Then, using some complex pattern-matching algorithms (say, using regular expressions), it looks for items like the innings, the team that is batting, the score, overs played, etc. It then strips out all the HTML tags, reformats it into HTML using the intranet style and shows the section on the intranet home page. This method is known as ‘Web Scraping.’

The client is very happy with the result and everything runs fine–till the day of a very important match–I’m sure you can guess which one! Unfortunately for Ramesh, on the day of this important match, the website that he was taking the information from suddenly decides to revamp its site’s design. Which means that the pattern-matching algorithms that Ramesh had painstakingly written are no longer valid–they return gibberish or worse yet,incorrect information. So what does one do?

The above scenario is of course, fictional and not of major importance. But imagine if the service being provided was not of cricket scores, but something much more crucial, like live stock quotes in a financial institution. A wrong pattern match could end up giving incorrect information to the user, which can lead to major financial turmoil. 

So what are the other methods that Ramesh could have used? There are some other obvious choices:

  • Ask the chosen site access to their cricket database. This is sure to be rejected by the site for obvious reasons.
  • Ask the chosen site for a remote procedure call interface. This is possible; however what happens if the site’s and the intranet’s technologies differ? For example, the site could be using a Java-based technology, and the intranet
    ASP/ASP.NET or vice-versa. In this case, one would have to write “wrappers” to use 
    the RPC calls from the other technology.
  • Ask the chosen site for a remote procedure call interface. If Ramesh is lucky, he may get a site that uses the same technology. For example, both his intranet as well as the remote site may use DCOM or RMI/IIOP. In which case, he can easily connect to the site and retrieve the data. However, in case the client has a strong firewall, he would not like to open a new port for a proprietary technology (DCOM or RMI/IIOP) for security’s sake. 

As you can see, Ramesh sure does have a problem on his hands, for a seemingly simple task. So what is the solution to this conundrum? The answer of course is Web
Services. 

A Web Service is a way of performing a remote procedure call using a standard protocol and a standard document model.

The standard protocol in this case is of course the HTTP (Hyper Text Transfer Protocol) and the document model is the XML (Extensible Markup Language). 

To put it simply, if a site “exposes” a Web service, a developer can use the service as an object and run any of the methods that the service has, just as if it were part of any other object. 

Let us now try to help Ramesh out by telling him about a Web Service that provides the cricket scores. What Ramesh does next is very simple. All he needs to do now is wrap the Web Service into an object and run it’s method to get data back in XML format. 

For example, assume that the site that gives the scores is at www.wc2003.com/scores.asmx. Here “scores” would be the Web Service, which can have different methods. Let one of the “methods” in scores be “LatestScores”. This returns the latest scores in XML format, which looks similar to the following:




India
42.5
2
250


Pakistan
0
0
0

Ramesh can easily pick up this information using any XML Parser and reformat to his heart’s content. If he is using .Net (ASP.NET or Windows Forms), most of the work can be done without writing any code at all!

All his other problems get solved too. Since Web services use HTTP and XML:

  • There is no problem regarding redesign of the page, spoiling pattern matching.
  • There is no need to try to gain access to the remote site’s business logic or database.
  • You do not face problems about incompatible technologies as when using different and often opposing solutions.

Most corporate firewalls allow HTTP to be open, even through a proxy. This is fine for Web Services as no new security issues are caused by them.

This article is, of course, a very quick and brief overview of Web Services. It is meant to show what the uses of Web Services are and the issues it aims to solve. There are, of course, a lot of technologies that go into making this possible. Do write in if you’d like to read more about this new technology and find out how to create Web Services and use them.

Vinod Unny is a Technology Consultant at Enterprise InfoTech

No Comments so far

Jump into a conversation

No Comments Yet!

You can be the one to start a conversation.

<