Amazon Web Services: SOAP or REST? - dummies

Amazon Web Services: SOAP or REST?

By Bernard Golden

Amazon Web Services (AWS) originally launched with SOAP support for interactions with its API, but it has steadily deprecated (reduced its support for, in other words) its SOAP interface in favor of REST. The best recommendation for any use of the AWS API is that you focus on using REST.

That way, you won’t end up with programs that someday stop working — long after you’ve forgotten the details of the interaction mechanisms. The experience of the unpleasant task of having to go back into a system and attempt to reconstruct your actions from months or years earlier is an unfortunate one.

There’s no sense in tempting fate with AWS — if you want to interact with the AWS API, use REST, which is Amazon’s long-term direction.

The older approach, SOAP (short for Simple Object Access Protocol), had widespread industry support, complete with a comprehensive set of standards. Those standards were too comprehensive, unfortunately. The people designing SOAP set it up to be extremely flexible — it can communicate across the web, e-mail, and private networks. To ensure security and manageability, a number of supporting standards that integrate with SOAP were also defined.

SOAP is based on a document encoding standard known as Extensible Markup Language (XML, for short), and the SOAP service is defined in such a way that users can then leverage XML no matter what the underlying communication network is. For this system to work, though, the data transferred by SOAP (commonly referred to as the payload) also needs to be in XML format.

Notice a pattern here? The push to be comprehensive and flexible (or, to be all things to all people) plus the XML payload requirement meant that SOAP ended up being quite complex, making it a lot of work to use properly. As you might guess, many IT people found SOAP daunting and, consequently, resisted using it.

About a decade ago, a doctoral student defined another web services approach as part of his thesis: REST, or Representational State Transfer. REST, which is far less comprehensive than SOAP, aspires to solve fewer problems. It doesn’t address some aspects of SOAP that seemed important but that, in retrospect, made it more complex to use — security, for example.

The most important aspect of REST is that it’s designed to integrate with standard web protocols so that REST services can be called with standard web verbs and URLs. For example, a valid REST call looks like this:

That’s all it takes to make a query to the REST service of examplecompany to see personnel information. The HTTP verb that accompanies this request is GET, asking for information to be returned. To delete information, you use the verb DELETE. To insert information, you use the verb POST. To update information, you use the verb PUT.

For the POST and PUT actions, additional information would accompany the empname and be separated by an ampersand (&) to indicate another argument to be used by the service.

REST imposes no particular formatting requirements on the service payloads; in this respect, it differs from SOAP, which requires XML. For simple interactions, a string of bytes is all you need for the payload; for more complex interactions (say, in addition to returning your employee information, you want to place a request for the employee information of all employees whose names start with G), the encoding convention JSON is used. (JSON, if you’re curious, stands for Javascript Object Notation.)

As you might expect, REST’s simpler use model, its alignment with standard web protocols and verbs, and its less restrictive payload formatting made it catch on with developers like a house on fire.