Leela's blog

Leela's picture

Web Services - SOAP and REST

What is a Web Service?
   
    A Web service is defined by the W3C as "a software system designed to support interoperable machine-to-machine interaction over a network".
   
    In other words, Web Services are frequently just a Web APIs that can be accessed over a network (like Internet) and executed on a remote system hosting the requested services.
   
How is Web Service different from a traditional RPC?

    RPC (Remote Procedure Call) belongs to the first generation distributed computing technology. They are typically used with in a enterprise, are dependent on a particular programming language, and are tightly-coupled with the object model and the implementing programming language. Subjected to these factors systems built on RPC technology doesn't support adhoc interaction across various RPC's across the internet.
   
    Web Services as defined are not dependent on a particular programming language are are not tightly-coupled with the object model of the service implementation as the communication under Web Services model is through exchange of XML messages and thus makes enterprise to enterprise communication in an ad-hoc manner over the internet.

Typical characteristics of Web Services:


    Web Services are based on -

  •         XML based every where
  •         Interaction happens with exchange of Messages (typically XML format)
  •         Independent of Programming Language
  •         Can be dynamically located and invoked (based on the industry standards - SOAP, WSDL, UDDI, etc.)
  •         Loosely Coupled to the object models as the external world interface is through XML Messages

       
Why Web Service?

  •     Interoperable - Connect across heterogeneous networks using ubiquitous web-based standards
  •     Economical - No installation and tight integration of software
  •     Automatic - No human interaction required even for highly complex transactions
  •     Accessible - Legacy and Internal applications can be exposed and accessible on the web
  •     Scalable - No limit on scope of applications and amount of heterogeneous applications 

Brief Notes on the Web Service Standards - SOAP, WSDL, UDDI and REST

SOAP

    SOAP (Simple Object Access Protocol) is a wire-protocol (like IIOP and JRMP). In other words, it specified rules of how data types get serialized over the wire. All the encoded data under SOAP protocol are in a XML representation.
    SOAP is a communication protocol for invoking business logics that are captured in component models like Java beans, EJB, etc.
    SOAP is not a programming language rather it is a portable communication protocol and all SOAP messages have to be produced, processed and manipulated by a programming language (Java is a most commonly used language for producing, processing and manipulating SOAP messages).
    SOAP communication protocol defines the following:

  •         Message Envelope - contains a SOAP Envelope and zero or more attachments. SOAP Envelope contains two parts - a Header, which is optional and contains context knowledge such as security and transactional related information, and a body part, contains application data or remote procedure call method and its parameter information. SOAP Attachment allows message to contain not only XML data but also non-XML data such as graphics, file, etc. It uses MIME multipart for these non-XML data.
  •         Encoding Rules - A set of rules of how to express application-defined data types on the wire in XML form. SOAP messages are constructed using the data types defined in W3C XML Schema. SOAP encoding supports both simple values (built-in data types from XML Schema) and compound values.
  •         Binding SOAP Message with underlying transport protocol like HTTP.
  •  

WSDL

    WSDL (Web Service Description Language) is a XML language for describing Web Services
    Using WSDL Web Service is described as a set of communication endpoints (ports) that are capable of exchanging messages. Each port is made of two parts. First part is abstract definitions of operations and messages. The second part is concrete binding of those abstract definitions of operations to concrete network protocol and message format.
    WSDL as a standard description of web services enables automation of communication details in an application to application communication. WSDL document can be used to identify various services available and how to make them without manual pre-arrangement or pre-configuration between the two.

UDDI
    The UDDI (Universal Description, Discovery, and Integration) standard provides a mechanism for businesses to "describe" themselves and the types of services they provide and then register and publish themselves in a UDDI Registry. Such published businesses can be searched for, queried, or "discovered" by other businesses using SOAP messages.

REST
    REST means REpresentational State Transfer. This architectural style of web service is defined by Roy Fielding in his P.Hd Thesis as contrary to the SOAP style of programming webservices. In this style of webservices all the messages are transferred over HTTP protocol and are sent as web traffic.RESTful services are stateless and each request from client to server must contain all the information necessary to understand the request. REST services are easy to work with as

  •         Clients do not need to use specialized API
  •         Clients just need to use standard HTTP
  •         You can use browser for experimentation and testing

    The main difference between RESTful services and SOAP based services are -

  •         SOAP based web services uses HTTP as transport for SOAP messages
  •         RESTful services uses HTTP as the protocol, no special protocol is used to exchange messages

 

Syndicate content