news
       about creditsafe
       terms and conditions
       what is getdata?
       how do i use getdata?
       faqs
       brochure
       register interest
       demonstration
       documentation
       example client applications
       testing
       knowledge base
       support
what is rest (or XML over HTTP)?

What is REST?
Why REST?
REST Example

What is REST?
REST stands for Representational State Transfer and is an architecture in which users submit an HTTP request to a specified Web Address (Uniform Resource Identifier - URI). The response to this request contains the data that was requested in some data format, such as an XML document. This architecture will be familiar to anyone who understands how the World Wide Web works as the Web is a REST-based system. On the World Wide Web a user submits an HTTP request through a browser to a URL and receives a web page in response, often formatted as an HTML document.

One of the distinguishing features of the REST architecture is that the client submits all the data to the service as part of the HTTP request. This contrasts with other web service architectures, such as Simple Object Access Protocol (SOAP), in which clients submit data to the service in the form of an XML document.

Why REST?
The World Wide Web consists of three elements:
  1. URI (Uniform Resource Identifier)
    The way of uniquely identifying resources on the network.

  2. HTTP (HyperText Transfer Protocol)
    The protocol used to request a resource from a URI and respond to requests.

  3. HTML (HyperText Markup Language)
    The content format of resources to be returned.

HTTP defines a small set of methods (GET, POST, PUT, DELETE etc.) and applies them to URIs. When using the Web the HTTP GET method is used to retrieve documents and the POST method is used to submit data. HTTPs power comes from its simplicity and extensibility. URIs are the defining characteristic of the Web and HTTP as a protocol defines methods as operations on URI-addressed resources.

REST allows HTTP and URIs to be used with any type of data (i.e. not just HTML) and other HTTP methods than the usual GET and POST. REST defines identifiable resources (URIs) and methods for accessing and manipulating the state of those resources (HTTP methods).

The idea of being able to link applications together using a standard open Remote Procedure Call (RPC) formats over HTTP connections shows great promise for distributed computing and interoperability. The major problem with RPC formats is they purposefully break the HTTP spec by adding another layer of abstraction onto HTTP rather than using the protocol as it was designed. REST says this extra layer is an unnecessary layer of complexity.

SOAP and RPC are both designed to operate from a single URI with methods being invoked from within the request. This fails to use URIs as they were designed to be used. A URI is a unique resource on the network and as such, each method in the RPC call should use a unique URI.Using REST this is the case, and depending on the request method, different actions can be invoked. REST uses HTTP as it was designed, to get some data use a HTTP GET request, to delete a record from a database use a HTTP DELETE request.

Advantages of REST:
  • It uses well documented, well established, well used technology and methodology.
  • Resource centric rather than method centric.
  • Given a URI everyone already knows how to access it.
  • REST is not another protocol on top of another protocol on top of another protocol etc.
  • The response message can be of any format.
  • Uses the inherent HTTP security model, certain methods to certain URIs can easily be restricted by firewall configuration, unlike other XML over HTTP messaging formats.

REST Example?
Figure 1 shows a sample REST HTTP Post request to a stock quote service.

POST /GetStockPrice
Host: http://www.stock.org
Content-Type: application/x-www-form-urlencoded
Content-Length: 3

StockName=IBM
Figure 1: Example REST Request

Figure 2 shows a sample REST response from the stock quote service.

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: 4

<xml version="1.0" encoding="utf-8">
<xmlns="http://www.stock.org/">
<double>
   34.5
</double>
Figure 2: Example REST Response

The response indicates a double return value (the current stock price).


© Copyright - Creditsafe Business Information NV