Cap 1 Introduction To Rest

REST and the Rebirth of HTTP

REST isn’t protocol-specific, but when people talk about REST, they usually mean REST over HTTP.
Rest al contrario di SOAP e Ws-*, che ne usano una piccola parte dell'http, usa questo protocollo in tutte le sue potenzialità.

Addressability

Addressability is the idea that every object and resource in your system is reachable through a unique identifier.
In the REST world, addressability is managed through the use of URIs.
The format of a URI is standardized as follows:
protocol://host:port/path?queryString#fragment
A path expression as a directory list of a file on your machine. Following the path expression is an optional query string. The “?” character separates the path from the query string. The query string is a list of parameters represented as name/value pairs. Each pair is delimited with the “&” character.
Esempio: http://example.com/customers?lastName=Burke&zipcode=02115
The last part of the URI is the fragment. It is delimited by a “#” character. The fragment is usually used to point to a certain place in the document you are querying.

Not all characters are allowed within a URI string. Some characters must be encoded using the following rules. The characters a–z, A–Z, 0–9, ., -, *, and _ remain the same.
The space character is converted to +. The other characters are first converted into a sequence of bytes using specific encoding scheme. Next, a two-digit hexadecimal number prefixed by % represents each byte.

Representation-Oriented

Representations could be XML, JSON,YAML, or really any format you can come up with.

Communicate Statelessly

Rest is stateless means that there is no client session data stored on the server. A service layer that does not have to maintain client sessions is a lot easier to scale, as it has to do a lot fewer expensive replications in a clustered environment.

HATEOAS

The final principle of REST is the idea of using Hypermedia As The Engine Of Application State (HATEOAS). Hypermedia is a document-centric approach with the added support for embedding links to other services and information within that document format.

Riassunto capitolo

REST identifies the key architectural principles of why the Web is so prevalent and scalable. The next step in the evolution of the Web is to apply these principles to the semantic Web and the world of web services. REST offers a simple, interoperable, and flexible way of writing web services that can be very different than the RPC mechanisms
like CORBA and WS-* that so many of us have had training in. In the next chapter we will apply the concepts of REST by defining a distributed RESTful interface to an existing business object model.

Salvo diversa indicazione, il contenuto di questa pagina è sotto licenza Creative Commons Attribution-ShareAlike 3.0 License