StrikeIron Web Services: Using REST
What is REST?
REST is an acronym for Representational State Transfer, an architectural style of
transferring data via XML using HTTP messages. Because REST does not contain the
abstraction of a more sophisticated protocol such as Simple Object Access Protocol
(SOAP), the data sent by REST tends to be less complicated than that sent by SOAP.
However, due to its ease-of-use, the REST interface is becoming a very popular way to
invoke a Web service.
Website developers often use REST to invoke a Web service from a Website because
it makes it easier to display XML data in a browser. Many commerce Websites are
making REST interfaces available for their various Web services today, including
Amazon, Yahoo, eBay, Google and Facebook.
REST Resources and URIs
An important concept in REST is the existence of resources (sources of specific information), each of which can be referred to using a global identifier (a URI). In order to manipulate these resources, components of the network (clients and servers) communicate via a standardized interface (such as HTTP) and exchange representations of these resources (the actual documents conveying the information). Developers use a Uniform Resource Identifier (URI) to refer to a resource. A Uniform Resource Identifier (URI) is a compact string of characters used to identify or name a resource. The main purpose of this identification is to enable interaction with
representations of the resource over a network, typically the World Wide Web, using specific protocols. URIs are defined in schemes defining a specific syntax and associated protocols. A benefit of using a URI is that a URI can be transmitted to another party and still make sense.
REST Versus SOAP
REST looks to build on the existing structure of the Web to create robust Web services,
while SOAP developers want to create a host of new specifications. Developers who
understand HTTP and XML can start building Web services immediately, without
needing any skills or tools other than what they normally use for Internet application
development. These same software designers have come to the conclusion that Simple
Object Access Protocol (SOAP) is overly complicated.
Here is the key to the differences between the two techniques: REST relies on a simple
set of "verbs" and puts all complexity into "nouns" that specify the resource. SOAP, on
the other hand, allows for a complex set of XML-formatted commands and data
transmission options. A REST-style request does not care what procedure is run; it just
asks for a named resource.
SOAP has a much more elaborate complex of standardization efforts and open source
toolkits. SOAP is also used if you need to publish your Web service with WSDL or
you need security functions such as message signing and encryption.
However, if a developer needs to make some information public with a simplified
interface and without using a lot of processor power, REST may be the preferred
method.