API PARADIGM SHIFT: SOAP TO REST

ankit yadav
Uvdesk Engineering
Published in
3 min readJan 3, 2017

APIs lets programmers build amazing tool and Apps even with different environments.

For those who may not be familiar with API,

What’s Api?

According to wikipedia, An application programming interface (API) is a set of subroutine definitions, protocols, and tools for building application software. In general terms, it’s a set of clearly defined methods of communication between various software components.
Server side Interface of API usually consists of standardized request-response System, typically referred as Web Services.

For developing a Api, you should follow one of design models like:

  • Rest
  • SOAP
  • JavaScript
  • XML-RPC

Two most dominant design models for API are SOAP and REST. SOAP used to be popular choice for making specific use Api(s). But, Now you can see paradigm shift from SOAP to REST. REST design model has gained enormous popularity, due to it’s simplicity and awesomeness.
As a developer you can follow any one as per your requirements. Let’s have a look at them:

SOAP

In short, SOAP(Simple Object Access Protocol) is a protocol specification for information transfer. It provides strongly type message format for API, and relies on XML format.

Example Request:

POST /url HTTP/1.1Host: HostServerNameContent-type: text/xml; charset=utf-8Content-length: 350SoapAction: http://tempUri.org/GetUserInfo<?xml version="1.0" encoding="utf-8" ?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetUserInfo xmlns="http://tempUri.org/"><UserID>1</UserID><OutputParam /></GetUserInfo></soap:Body></soap:Envelope>

Example Response:

<?xml version="1.0" encoding="utf-8" ?><SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" ...><SOAP-ENV:Body><method:MethodNameResponse><method:MethodNameResult xmlns="" xsi:type="sqlresultstream:SqlResultStream"><!-- the results are returned here --></method:MethodNameResult><method:OutputParam>Value</method:OutputParam></method:MethodNameResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

Rest

REST is an architectural style, unlike SOAP which is a standardized protocol. it makes use of HTTP and uses HTTP methods explicitly. It can structure api data into JSON, XML, YAML, HTML or any other format. JSON is preferred format. Unlike SOAP, you don’t need to use verb for action but corresponding HTTP Methods like GET, PUT, DELETE, POST, PATCH.

Example Request:

GET /ticketAccept: application/jsonContent-Type: application

Example Response:

200 OKContent-Type: application/json{"ticket": {"id": 11174,"incrementId": 82,"subject": "ticket subject","isStarred": null,"isAgentView": true,"isTrashed": false,"source": "website","group": null,"priority": {"id": 1,"name": "Low","description": "Low","color": "#5cb85c"},"formatedCreatedAt": "21-Dec 10:36am","totalThreads": "0","agent": {"id": 1724,"name": "agent name"},"customer": {"id": 193,"name": "customer name"},"hasAttachments": 0}}

More and more sites like UVdesk are following REST design pattern.
Because REST have many advantages over SOAP like

  1. ReST leverages HTTP, so everything is simple.
  2. In ReST metadata and URI are nouns, action are specified by HTTP Methods like GET, PUT, POST, DELETE, PATCH, HEAD.
  3. Rest API(s) are more suitable for mobile devices. so, if you may use your API for mobile Apps then ReST API is right choice for you.
  4. multiple data formats can be supported like JSON, YAML, XML, while SOAP provides only XML format.
  5. ReST services are cacheable.
  6. Normally, ReST is faster than SOAP. Since, it uses JSON format rather than XML.
  7. Rest following community is quite big. so, You can easily find suitable library for ReST implementaion.

What’s Next?

If you have selected suitable Design Model. Then, Stay connected for upcoming API category stories . In Upcoming stories, You can have a look at our full journey of API development. Furthermore, there will all sort of tricks, tweaks and key points that we learned while developing REST API.

Note: Story can also be viewed on UVdesk Blog .

--

--