SOAP API
|
REST API
|
Simple Object Access Protocol
|
Representational State Transfer
|
It is based on standard XML format
|
It is based on URI
|
It works with WSDL
|
It works with GET, POST, PUT, DELETE
|
Works over with HTTP, HTTPS, SMTP, XMPP
|
Works over with HTTP and HTTPS
|
REST
REST’s sweet spot is when you are exposing a public API over the internet to handle CRUD operations on data. REST is focused on accessing named resources through a single consistent interface.
REST uses stateless protocol. So, it does not require the server to retain session information or status about each communications partner for the duration of multiple requests. REST API requires TLS protocol.
SOAP
SOAP brings it’s own protocol and focuses on exposing pieces of application logic (not data) as services. SOAP exposes operations. SOAP is focused on accessing named operations, each implement some business logic through different interfaces.
While SOAP supports SSL (just like REST) it also supports WS-Security which adds some enterprise security features. Supports identity through intermediaries, not just point to point (SSL). It also provides a standard implementation of data integrity and data privacy.
Advantage of SOAP is that it offers built-in retry logic to compensate for failed communications. REST, on the other hand, doesn’t have a built-in messaging system. If a communication fails, the client has to deal with it by retrying. There’s also no standard set of rules for REST. This means that both parties (the service and the consumer) need to understand both content and context.