Smarter ideas worth writing about.

Making the Switch to REST from SOAP

 

There is much discussion today about whether companies should choose REST or SOAP to serve web service requests to their clients. In this post, I’d like to help formulate a clear picture of what each offers over the other.

 

Advantages of SOAP

SOAP has been in use since 1998. If you’re an application server developer, you probably have at least a passing familiarity with it. Companies are very comfortable with it, and its standard is well-documented. 

  • SOAP is easy to consume in almost any programming language. Almost every modern language and framework has some method of parsing XML, and they typically expose some framework available for handling SOAP requests out of the box.
  • Because SOAP exposes its capabilities in the form of a WSDL file, it is self-documenting, and, for a lot of programming languages, the code required to make or consume a web service request can be generated on the fly. This gives service developers the ability to make a change to the WSDL and all of its clients will be able to respond to the change relatively effortlessly. 
  • SOAP allows for strict type-checking on fields. You can validate SOAP requests against the WSDL and immediately see if a required field is missing or if a value being passed is of the wrong type or is formatted incorrectly. This cuts down on a lot of the back-and-forth Q&A between service developers and client developers.
  • SOAP supports out of the box WS-* transactions. WS-* transactions offer protocol independence and the ability to address common enterprise concerns such as security and providing a transactional interface. 

 

Advantages of REST

REST has been around since 2000, although  it didn’t fall into wide usage until recently. Most web services that serve mobile devices expose these services as REST. 

  • REST can return a response in many different MIME types. If the service is configured correctly, a client need only specify an Accept header with the appropriate value and the service will format the response accordingly. Typically REST services can return responses in XML, JSON, or HTML format.
  • Since there are no extra request/response headers, REST is much more lightweight than other web service paradigms. REST consumes less bandwidth and decreases response time for service calls. 
  • The lack of extra markup also makes the request/response bodies human-readable. Because of this, the services are easy to consume with very little documentation.
  • This simplicity leads to inherent shortening of development time. If a developer knows the URI of a given service, he or she can craft a request using the standard HTTP protocol without any knowledge of the implementation of the web service.

 

Going Mobile

From a mobile perspective, I believe that REST offers specific advantages over SOAP. 

  • Its primary advantage is that both iOS and Android offer a built-in framework for consuming RESTful web services. This leads to a significant reduction in development time in that one does not have to develop the infrastructure required to consume SOAP services. iOS offers some rudimentary frameworks for generating code for SOAP, but there is still a lot of manual intervention on the part of the developer. It is generally difficult to respond quickly to changes to the service because these modifications must be repeated every time the code is regenerated. Android is a bit simpler because there are some third-party libraries available to handle the SOAP, and Java has a long history with the SOAP standard, but it is still not available out of the box.
  • REST’s lightweight nature also makes it a better candidate for use on mobile devices. Users don’t want to use applications that drain their battery. More data transfer means more battery usages. In the face of increasing bandwidth caps on mobile data plans, users expect developers to optimize their service calls as much as possible. The extra request/response headers may only add 2kB to a single request or response, but this extra overhead can add up after many repeated requests.

Both REST and SOAP remain in wide usage across the software industry and offer clear advantages depending on the specific usage scenario. In mobile, however, due to both the native ability of the framework to handle REST requests, its lightweight nature, and its ability to accept requests and offer responses in multiple MIME types, REST offers a significant advantage over SOAP.

Share: