Tuesday, December 29, 2009

What is Web Service

-Satya Prakash
 The Internet has become something it never has been. We are connected to every other in a way that has never been in human history. This is a web of information, interaction, but at the same time it is a web of possibilities. Possibilities of friends, collaboration, learning and also a possibility of service providing and consuming. Business-to-business (B2B) relations through computer networks have a comparably long history, but a history with a separation of protocols, languages, standards. But The Web is one. With its user and producer-friendliness, HTML became universal, as well as XML that is similar. And a technology of a more connected world is being developed: Web Services.

                                          Simply put, Web Services are service requesting and providing, by sending and receiving messages of some format. The messages are commonly XML formatted. Most desired features of Web Services are interoperability between different systems, perfect security and quality (as it is for business use), easy interpretation and implementation.

BASIC CONCEPTS
Let us look at some basic concepts concerning this technology.

A human friendly format: XML
                                       In Web Services, many message formats are based on Extensible Markup Language (XML) which is a very general purpose markup language that is used in variety of applications. In every XML file, there are entities that are structured as a tree. It is a method of representing information that is both human readable and machine readable. Positive attributes of XML are:

         • Being both human and machine-readable
         • Unicode support, thus supporting nearly every human language
         • The tree structure is very appropriate for computer science abstractions
         • Names and values are openly written, making it a self documenting format
         • The format allows efficient parsing

And its weaknesses:
        • Its redundant, unnecessarily long format is a problem for efficient storage and transmission
        • With the same reason, every XML parser must check a file's format thoroughly to prevent errors
        • In XML there is no data type such as int or float, everything must be expressed through strings
        • The hierarchical model of XML is limited, compared to relational models such as databases. Representing non-hierarchical data in XML is difficult.

 Message format: SOAP
                         Web Services generally use SOAP as a message envelope format. Simple Object Access Protocol (SOAP) is a messaging protocol that is based on XML used usually with HTTP. The original acronym was dropped with version 1.2 as it was misleading, it became only SOAP. SOAP forms the second layer of Web services protocol stack, more abstract layers build on it. These are “service description” protocols such as WSDL, and “service discovery protocols” such as UDDI.
                                      Most widely used messaging pattern of SOAP is Remote Procedure Call (RPC). In fact, SOAP evolved from XML-RPC that was only capable of RPC messaging. SOAP was designed by Dave Winer, Don Box, Bob Atkinson, and Mohsen Al-Ghosein in 1998. Its specifications are currently maintained by XML Protocol Working Group of W3C. It was intended to be a protocol to allow software applications to interact on the internet or any network.

Let us look at an example SOAP request and response:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getProductDetails xmlns="http://warehouse.example.com/ws">
<productID>007</productID>
</getProductDetails>
</soap:Body>
</soap:Envelope>

Above is a SOAP formatted request example. It uses the operation “getProductDetails” to get information about the product with ID 007. This message is independent of the operating system or any inner structure of the server.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getProductDetailsResponse xmlns="http://warehouse.example.com/ws">
<getProductDetailsResult>
<productName>Toptimate 3-Piece Set
</productName>
<productID>007</productID>
<description>3-Piece luggage set.Black Polyester.</description>
<price>96.50</price>
<inStock>true</inStock>
</getProductDetailsResult>
</getProductDetailsResponse>
</soap:Body>
</soap:Envelope>

This is the response of the server. The operation is realized, and product details are returned to the client. SOAP messages are text based and very easy to read. This is also a weakness as a limitation to transfer speed, because the messages are very long and this may affect network performance. Some other technologies such as CORBA use binary format and do not bear this weakness. This is a general problem of XML-based protocols.

Transferring messages: HTTP
                                  SOAP messages are transferred using Hypertext Transfer Protocol (HTTP). HTTP is a method used to transfer or convey information on the World Wide Web. Its original purpose was to provide a way to publish and retrieve HTML pages. It is also used to transfer XML files and XML-based file formats such as SOAP.
HTTP is used between clients and servers as a request/ response protocol. The connecting agent, a client, a web browser, or any other end-user application, is described as the “user agent”. The destination server is called the origin server. Resources such as HTML files and images are stored or created in the server. In between the user agent and origin server may be several intermediaries, such as proxies, gateways, and tunnels.

Service description: WSDL
                                  Web Services Description Language (WSDL) is an XML based language for communicating descriptions of Web Services. WSDL defines services as a collection of “ports” that receive and send “messages”. But these are taken as abstract concepts and separated from their concrete use or instance.
                                                        A “port” is a network address that can be reused through binding. A “port type” is an abstract collection of supported operations. A “service” is a collection of ports. “Message” is defined as abstract definitions of data that is transferred. WSDL describes the public interface for a particular Web Service by using these concepts.
WSDL is generally used with SOAP. If a client program connects to a Web Service, it can get the WSDL to understand what operations are available on the server. Special data types are written in WSDL in XML Schema format. Then SOAP messages are used for calling the functions on the server.

A universal registry: UDDI
                                    There is a standard registry for Web Services. It is Universal Description, Discovery, and Integration (UDDI). UDDI is an XML-based list of businesses. It was written in August 2000, and it is sponsored by OASIS. It is like a platform or market that different businesses find each other's services and interact over the Internet. Every business registers on the following:

              • White Pages that include addresses, contact information
              • Yellow Pages that include sectoral categorizations based on standard classifications
              • Green Pages that include technical information about the services proposed

UDDI is queried by SOAP messages. Clients send SOAP messages to the UDDI to get service descriptions in WSDL. And then, using the protocol bindings and message formats described in WSDL documents, the client can use any service that is offered in UDDI by several businesses.

No comments:

Post a Comment