Tuesday, February 8, 2011

QTP Web Services

What are web services?

Web Services: A vague term that refers to distributed or virtual applications or processes that use the internet to link activities or software components.

With the use of Web services, an application can publish its function or message to the rest of the world.

For example a travel website that takes a reservation from a customer, and then sends a message to a hotel application, accesses via the web, to determine if a room is available, books it, and then tells the customer he or she has a reservation is an example of a web services application. [Real world web services By Will Iverson]

Why web services are important when we have other technologies like RMI, CORBA etc.?

Web Services are platform-independent and language-independent, since they use standard XML languages. This means that my client program can be programmed in C++ and running under Windows, while the Web Service is programmed in Java and running under Linux.

Most Web Services use HTTP for transmitting messages (such as the service request and response). This is a major advantage if you want to build an Internet-scale application, since most of the Internet's proxies and firewalls won't mess with HTTP traffic.

One of the oft-cited advantages of web services is the fact that they lend themselves naturally to build loosely coupled systems. These types of systems are more scalable than strongly coupled systems, and impose fewer architectural requirements on the actual implementation of the web services. Suffice it to say that the reason why web services are ideal to build loosely coupled systems is because they are message-oriented and rely on language-neutral XML dialects to send messages, to specify interfaces, etc.

What are the disadvantages of web services?

Overhead: Transmitting all your data in XML is obviously not as efficient as using a proprietary binary code. What you win in portability, you lose in efficiency. Even so, this overhead is usually acceptable for most applications, but you will probably never find a critical real-time application that uses Web Services.

Lack of maturity: Web Services are relatively new and, though the core specifications that deal with fundamental languages (XML, WSDL,..) and protocols (HTTP, SOAP,…) are pretty stable the world of web services is still evolving at a fast pace. Standards dealing with more advanced capabilities expected from distributed systems, such as transactions, security, etc. are either very new or still in the works. [Globus Toolkit 4: programming Java Services By Borja Sotomayor, Lisa Childers]

Some Definitions:

Web Services Description Language (WSDL)

WSDL (Web Services Description Language) is an XML-based language for describing Web services and how to access them. You can see more on it here.

SOAP (Simple Object Access Protocol, or Service Oriented Architecture Protocol)
SOAP is a simple XML-based protocol to let applications exchange information over HTTP. You can see more on it here.

UDDI (Universal Description, Discovery and Integration)

Universal Description, Discovery and Integration (UDDI) is a directory service where businesses can register and search for Web services.

UDDI is a platform-independent framework for describing services, discovering businesses, and integrating business services by using the Internet.

UDDI stands for Universal Description, Discovery and Integration
UDDI is a directory for storing information about web services
UDDI is a directory of web service interfaces described by WSDL
UDDI communicates via SOAP
UDDI is built into the Microsoft .NET platform
You can see more on it here.

A small example of Web Service (invocation) to make it even more understandable:

1. A client may have no knowledge of what Web Service it is going to invoke. So, our first step will be to discover a Web Service that meets our requirements. For example, we might be interested in locating a public Web Service which can give me the weather forecast in US cities. We'll do this by contacting a discovery service (which is itself a Web service).

2. The discovery service will reply, telling us what servers can provide us the service we require.

3. We now know the location of a Web Service, but we have no idea of how to actually invoke it. Sure, we know it can give me the forecast for a US city, but how do we perform the actual service invocation? The method I have to invoke might be called "string getCityForecast(int CityPostalCode)", but it could also be called "string getUSCityWeather(string cityName, bool isFarenheit)". We have to ask the Web Service to describe itself (i.e. tell us how exactly we should invoke it).

4. The Web Service replies in a language called WSDL.

5. We finally know where the Web Service is located and how to invoke it. The invocation itself is done in a language called SOAP. Therefore, we will first send a SOAP request asking for the weather forecast of a certain city.

6. The Web Service will kindly reply with a SOAP response which includes the forecast we asked for, or maybe an error message if our SOAP request was incorrect.
For more on web services you can read [Globus Toolkit 4: programming Java Services By Borja Sotomayor, Lisa Childers]