Introducing REST and JSON

SOAP is just one standard for implementing web services, but it is not the only one. Another popular style of implementation is to use REST to define a service’s location and make calls to the service, and JSON to define the data. REST is a simple style of calling web services that is closely tied to the verbs (e.g., GET and POST) provided by HTTP, and JSON is a simple alternative to XML that is based on how data is defined in JavaScript. One important advantage of SOAP is that it is strictly defined, and when it is coupled with WSDL, it is easier to write tools that automatically generate proxies. REST and JSON are very simple protocols which are easy to code against in any language without the need for tools, and parsing of JSON is built into JavaScript. JSON also often uses less bandwidth than XML.

REST

REST stands for Representational State Transfer, and it is a style of service rather than an exact specification. REST services consist of a number of uniquely identifiable “resources,” and there are only four operations one can perform with a resource: read it, modify it, delete it, or create a new one.

When REST services are exposed over HTTP (as is typically the case), URIs are used to refer to server-side resources, and operations on those resources are represented as the HTTP verbs GET, POST, DELETE, and PUT.

A simple example is a book database. A URI to a book could be:

http://bookdatabase.oreilly.com/books/ISBN/<isbn_id>

where isbn_id is the unique identifier ...

Get Programming ASP.NET 3.5, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.