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.

Quick Notes Finder Tags

Activities (1) advanced java (1) agile (3) App Servers (6) archived notes (2) Arrays (1) Best Practices (12) Best Practices (Design) (3) Best Practices (Java) (7) Best Practices (Java EE) (1) BigData (3) Chars & Encodings (6) coding problems (2) Collections (15) contests (3) Core Java (All) (55) course plan (2) Database (12) Design patterns (8) dev tools (3) downloads (2) eclipse (9) Essentials (1) examples (14) Exception (1) Exceptions (4) Exercise (1) exercises (6) Getting Started (18) Groovy (2) hadoop (4) hibernate (77) hibernate interview questions (6) History (1) Hot book (5) http monitoring (2) Inheritance (4) intellij (1) java 8 notes (4) Java 9 (1) Java Concepts (7) Java Core (9) java ee exercises (1) java ee interview questions (2) Java Elements (16) Java Environment (1) Java Features (4) java interview points (4) java interview questions (4) javajee initiatives (1) javajee thoughts (3) Java Performance (6) Java Programmer 1 (11) Java Programmer 2 (7) Javascript Frameworks (1) Java SE Professional (1) JPA 1 - Module (6) JPA 1 - Modules (1) JSP (1) Legacy Java (1) linked list (3) maven (1) Multithreading (16) NFR (1) No SQL (1) Object Oriented (9) OCPJP (4) OCPWCD (1) OOAD (3) Operators (4) Overloading (2) Overriding (2) Overviews (1) policies (1) programming (1) Quartz Scheduler (1) Quizzes (17) RabbitMQ (1) references (2) restful web service (3) Searching (1) security (10) Servlets (8) Servlets and JSP (31) Site Usage Guidelines (1) Sorting (1) source code management (1) spring (4) spring boot (3) Spring Examples (1) Spring Features (1) spring jpa (1) Stack (1) Streams & IO (3) Strings (11) SW Developer Tools (2) testing (1) troubleshooting (1) user interface (1) vxml (8) web services (1) Web Technologies (1) Web Technology Books (1) youtube (1)