Service Oriented Computing
Akshaya Ganesan
Assistant Professor[Off-Campus]
BITS-Pilani
Precap
• Introduction to REST (Representational State Transfer)
• REST architectural style
• REST constraints
Agenda
• REST and Resources
• Addressability
• Statelessness
• Connectedness
• Uniform Interface
REST is about…
1. Resources
2. Their names (URIs)
3. Their representations
Example URI:
[Link]
4. Relationship between URI and Resources • [Link]
• [Link]
• [Link]
Four main properties
• 1. Addressability
• Consider a URI: [Link]
• 2. Statelessness
• Application state vs Resource state
• Application state is kept on the client, but the server can manipulate it by sending representation that
describe the possible state transitions.
• Resource state is kept on the server, but the client can manipulate it by sending the server a
representation that describing the desired new state.
• A Representation Describes Resource State
• 3. Connectedness
• HATEOS
• 4. A uniform interface
Key principles
• Everything is a resource
• Each resource is identifiable by a unique identifier (URI)
• Use the standard HTTP methods
• Resources can have multiple representations
• Communicate statelessly
Best Practices
Use only nouns for a URI;
GET methods should not alter the state of resource;
Use plural nouns for a URI;
Use sub-resources for relationships between resources;
Use HTTP headers to specify input/output format;
Provide users with filtering and paging for collections;
Version the API;
Provide proper HTTP status codes.
Example
• The browser makes an HTTP request:
• POST /messages HTTP/1.1
• Host: [Link]
• Content-type: application/x-www-form-urlencoded
• message=Test&submit=Post
• And the server responds with the following:
• HTTP/1.1 303 See Other
• Content-type: text/html
• Location: [Link]
REST Maturity Model
Richardson Maturity Model ([Link])
Richardson used three main factors to decide
the maturity of a service. These factors are
URI,
HTTP Methods,
HATEOAS (Hypermedia)
References
1) Restful Web services, Leonard Richardson and Sam Ruby, 1 st edition published by O'Reilly
Media,
2) REST API Design Rulebook by Mark Massé
Thank You!
In our next session: