Tuesday, October 12, 2010

Web Services

First of all, there's web and then there's Web Services. What is so special about these web services; is it different from the web?
To be frank, it is different from the web and the specialty lies in the fact that it enables systematic application-to-application interaction on the web. It acts like a distributed computing platform for web. Universal interoperabilty and a Service Oriented Architecture (SOA) were two major expectations of implementing web services.


The W3C definition for web services is,
A Web service is a software application identified by a URI, whose interfaces and binding are capable of being defined, described and discovered by XML artefacts and supports direct interactions with other software applications using XML based messages via internet-based protocols.


The Service Oriented Architecture of web services comprises of a Service Requester, a Service Registry and a Service Provider. In other words, Web services platform elements are:
  • SOAP (Simple Object Access Protocol)
  • UDDI (Universal Description, Discovery and Integration)
  • WSDL (Web Services Description Language)
All the technologies in web services are XML and HTTP based. There are several reasons for the usage of XML:
  • XML is pure text with no binary data
  • Applications read the XML
  • Applications share data using XML . Any application can talk to any other application using XML (unlike binary) irrespective of the platform
  • XML is a method for putting structured data in a text file
One of the web service platform elements being SOAP, it is essential to understand what it is for.
Basically, SOAP is an XML-based protocol to let applications exchange information over HTTP. In order to access a web service, we have to send a SOAP message. A SOAP message is an XML stream, which is used to transmit messages via HTTP.  
SOAP Structure is indicated below:


  • Envelope:encloses the entire SOAP message being the root element
  • Header
  • Body
    • Message


E.g.:-
<SOAP-ENV:Envelope    
   xmlns="http://schemas.xmlsoap.org/soap/envelope/"> 
     < SOAP-ENV:Header>
      ...
     </ SOAP-ENV:Header> 
     < SOAP-ENV:Body>
       ...
     </ SOAP-ENV:Body>
    ...
</  SOAP-ENV: Envelope>  




WSDL is an XML-based language used to define Web Services and also describe how to  access them. It happens to be the external interface for a client (IDL).
WSDL includes information about the following:
  • Data types it uses
  • Parameters it requires and returns
  • Groupings of functionality
  • The protocol to be used to access the service
  • The location or address of the service  
WSDL Structure has the follwing elements:
  • <definition> - Root element
  • <types> - Provides data type definitions
  • <message> - Represents the abstract definition of the data being transmitted
  • <portType> - Defines a set of abstract operations
  • <binding> - Specifies concrete protocol and data format specifications for the operations and messages defined by a particular portType
  • <port> - Specifies an address for a binding
  • <service> - Used to aggregate a set of related ports
  • <serviceType> - Mechanism to aggregate portTypes
UDDI  defines the operation of a service registry. For example,
  • S/W companies, standards bodies, and programmers populate the registry with descriptions of different types of services
  • Then Businesses populate the registry with descriptions of the services they support 
  • Marketplaces, search engines, and business apps query the registry to discover services at other companies 
  • Finally, Businesses use this data to facilitate easier integration with each other over the Web