REST Vs SOAP

Introduction

In the mad rush of implementing Rest Services, I will be discussing about key scenarios for REST Vs SOAP i.e when it is best suited to implement REST Vs SOAP or vice-versa.

Can REST fully Replace SOAP? To answer let's understand what is SOAP and REST?

SOAP – Simple Object Access Protocol.

  • Exposes Operations that implements business Logic.
  • It provides loose coupling to integrate hybrid systems.
  • SOAP supports standard error Messaging
  • Designed for:
    • Extensible
    • Distributed Computing
  • SOAP service very well suited for Enterprise Applications needs & goals:
    • Supports HTTP, SMTP, JMS
    • Enterprise security with WS-Security
    • Supports ACID, Atomic transactions with WS-AT
    • Lot of development tools available
  • Supports HHTP POST
  • Supports only XML
  • Supports stateless & stateful operations
  • Strongly typed.
  • Supports asynchronous messaging

REST – Representational State Transfer

  • Exposes Resources which represent Data
  • Use HTTP methods (GET/POST/DELETE)
  • Based on simple Point to Point communication over HTTP.
  • Stateless communication
  • Supports multiple Formats

Key Advantages of REST?

  • REST can be consumed by any client like web browser, AJAX, JQuery, Javascript
  • REST is definitely lightweight
    • Doesn't requires XML parsing
    • Consumes less bandwidth
    • Doesn't require SOAP header for every message.

Key Challenges with REST?

  • Building a client in REST can be challenging:
    • Can't generate client side artifacts from WSDL as in case of SOAP
    • Need to write raw HTTP calls.
    • Not many IDE available to write REST Clients
  • Rest only Support HTTP / HTTPS
  • REST is not secure.
    • Parameters are part of the URI
    • No support for acquiring tokens
  • RESTFul Services has no contract.
  • REST is not reliable
  • REST can't be governed as it doesn't have any service registry.

What's is Verdict for REST vs SOAP?

Both REST & SOAP are best suited for following respective scenarios

REST SOAP
Best Suited for:
  • Web Services.
  • Smaller size messages (Limited bandwidth)
  • Limited resources (No XML parsing required)
  • Exposing data over Internet.
  • Combining content from different sources / SORs in a web browser.
Best Suited for:
  • Enterprise Services
    • High availability WS-RM
    • Supports transactions WS-AT
    • Supports security WS-Security
    • Asynchronous Processing
    • Contract based development
    • Supports interoperability with business applications.

Coming next is REST API Design, till then happy reading and blogging.

Ebook Download
View all
Learn
View all