API

SOAP & REST Basics

Posted by Danni on November 25, 2018

soap-vs-rest Soap V.S. Rest

Recently I’ve been using API a lot. Coming across such terms makes me think more about the underlying protocol of the communication system over the WWW. It’s well known that this system can be categorized into two types, SOAP(Simple Object Access Protocol) and REST(Representational State Transfer). But how does them work? Is there any difference? Can they be used for the same purpose or have their own specialized area? I did some digging over the internet and here are my thoughts.

SOAP

SOAP is a standard communication protocol system that permits processes using different operating systems like Linux and Windows to communicate via HTTP and its XML. SOAP-based APIs are designed to create, recover, update and delete records like accounts, passwords, leads, and custom objects. It is the XML-based messaging protocol for exchanging information among computers. SOAP is an application of the XML specification. Its initial focus is remote procedure calls transported via HTTP.

Other frameworks including CORBA, DCOM, and Java RMI provide similar functionality to SOAP, but SOAP messages are written entirely in XML and are therefore uniquely platform- and language-independent.

REST

REST is a software architectural style. Such style allows for more effective communication without between clients(browsers) and servers. It advocates that web applications should use HTTP as it was originally envisioned. Lookups should use GET requests. PUT for mutation, POST for creation, DELETE for deletion respectively.

Any software that follows the REST architectural style is said to be RESTful, hence the name “RESTful web service”. Any application programming interface following the REST can be called REST APIs.

A web service is a software that (1) provides functionalities for other software (2) over the web. An example of a RESTful web service is the Github API. To get information about a Github user, you can send a GET request to api.github.com/users/your-user-name

https://medium.com/@donovanso/what-is-a-restful-web-service-a5280f795c89

Difference between API and web services is that: In short, an API (application programming interface) refers to any methods that allow different software components to communicate with each other. A web service, on the other hand, is an API that works over the web. So, web services are a subset of APIs. All Web services are APIs but not all APIs are web services.

https://medium.com/@donovanso/what-is-a-restful-web-service-a5280f795c89

Difference

REST API has no has no official standard at all because it is an architectural style. SOAP API, on the other hand, has an official standard because it is a protocol.

REST APIs uses multiple standards like HTTP, JSON, URL, and XML while SOAP APIs is largely based on HTTP and XML.

As REST API deploys multiple standards, so it takes fewer resources and bandwidth as compared to SOAP that uses XML for the creation of Payload and results in the large sized file.

The ways both APIs exposes the business logics are also different. REST API takes advantage of URL exposure like @path(“/WeatherService”) while SOAP API use of services interfaces like @WebService.

SOAP API defines too many standards, and its implementer implements the things in a standard way only. In the case of miscommunication from service, the result will be the error. REST API, on the other hand, don’t make emphasis on too many standards and results in corrupt API in the end.

REST API uses Web Application Description Language, and SOAP API used Web Services Description language for describing the functionalities being offered by web services.

REST APIs are more convenient with JavaScript and can be implemented easily as well. SOAP APIs are also convenient with JavaScript but don’t support for greater implementation.

https://dzone.com/articles/difference-between-rest-and-soap-api