Types of Web Services - SOAP and REST

WebServices can be roughly divided into two types based on the architecture they follow:

  1. SOAP-based web services

  2. Restful web services

 

SOAP Based web services

  1. SOAP-based web services were the original kind of web services

  2. They follow RPC-style

    • An RPC-style web service accepts an envelope full of data from its client, and sends a similar envelope back.

    • The method and the scoping information are kept inside the envelope. HTTP is a popular envelope format.

    • SOAP is another popular envelope format (transmitting a SOAP document over HTTP puts the SOAP envelope inside an HTTP envelope).

  3. SOAP Services can be located and invoked by client applications over a network (e.g. internet) automatically without human interaction.

    • To make the automatic locating and invocation possible SOAP web services were designed as self describing through the use of a message protocol called SOAP, service definition called WSDL and a way to locate other web services using UDDI

    • SOAP web services are self-describing and self-contained, as the definition of the message format (WSDL and/or XSD) travels with the message or is accessible to the client, and the server and client requires only minimal software - an HTTP server and/or a SOAP server on the server side and on the client side no additional s/w is required. 

  4. SOAP is based on rules whereas REST is based on guidelines.

    • SOAP web service defines a new vocabularies, standards and protocols.

  5. In SOAP based webservices messages (requests and responses) are exchanged in an XML format called SOAP. 

    • SOAP originally stood for Simple Object Access Protocol, but now some also call it as Service Oriented Architecture (SOA) protocol. 

  6. Though HTTP is the most commonly used protocol with SOAP-based webservices, it is not limited to just HTTP, but can also use other protocols like SMTP, JMS etc

    • A SOAP-based service delivered over HTTP can be considered as a special case of a REST-style service.

  7. In SOAP, the endpoint url will be same for a service that represent a set of operations and different operations are requested using specifics in the request body.

  8. Definition about the service is stored in a document called WSDL in case of SOAP. When a client get a wsdl, it will have all information regarding a SOAP web service.

  9. The request-response pattern is supported by both SOAP and REST. SOAP based services also support other message exchange patterns like one way input, solicit response and publish-subscribe.

  10. You need a specialized client that can send SOAP requests in case of SOAP.

    • SOAP UI is a popular tool that can do this.

    • You may also write a Java client using JAX-WS on your own.

 

RESTful web services

  1. Restful web services came later and is more popular now

  2. They follow a resource oriented way. Every resource will be reprecented by an URI and its current state of representation is transferred using formats such as XML and JSON.

  3. REST web services are not automatically located using an UDDI registry as in case of SOAP web services.

  4. SOAP is based on rules whereas REST is based on guidelines

    • Restful web services share a standard vocabulary of HTTP methods.

      • Every object in a Restful service responds to the same basic interface. 

  5. In a REST-style service, a client might send a standard HTTP request to a web service and receives an appropriate response in a MIME-TYPE of their choice like XML, Text, JSON, user-defined etc.  

  6. HTTP is the only transport protocol for REST. 

  7. REST usually have a single url for a resource and uses the standard set of http operations like POST, GET, PUT, and DELETE, to do various operations on that resource.

    • Note that REST is based on guidelines and not rules as in the case of SOAP. So there is nothing which will enforce you to use a particular approach in REST, like in the case of SOAP.

  8. There is no formal definitions for REST like the WSDL for SOAP. There are some definition formats like WADL, but they have not become very popular. 

  9. REST support only request-response message exchange pattern.

  10. You can make requests to a RESTful web service using your programming language’s HTTP client library or even from your web browser if it is a GET request.

    • There are also plugins available to most browsers.

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!