3. REST is not
a Protocol
an Architecture
a Software
a Standard
a fancy name for Web Services
a Buzzword
4. Representational
State
Transfer
Roy T. Fielding
“Architectural Styles and the Design of Network-based Software Architectures”
Ph.D dissertation, 2000
5. REST is
a Software Architecture Style
a set of Constraints on Component
Interaction that, when obeyed, cause
the resulting Architecture to have
certain properties
Roy T. Fielding http://roy.gbiv.com/untangled/2008/on-software-architecture
7. prediction for 2009
“Roy Fielding will officially disown most of the
RESTful authors and software packages
available. Nobody will care, or worse, somebody
looking to make a name for themselves will
proclaim that “Roy doesn't really understand
REST”, and they'll be right: Roy doesn't
understand what they consider to be REST”
http://dotnet.dzone.com/articles/ted-neward-2009-predictions-20
8. why?
“... the motivation for developing REST was to
create an architectural model for how the Web
should work, such that it could serve as the
guiding framework for the Web protocol
standards”
http://www.ics.uci.edu/~fielding/pubs/dissertation/evaluation.htm
43. GET /position/wqd3,wkd2,bke8.gif HTTP/1.1
Accept: image/gif
HTTP/1.1 406 Not Acceptable
or more friendly
HTTP/1.1 300 Multiple Choices
Content-Type: application/xml
n
<choices><content type=”image/png” uri=”...”>
46. GET /game/42 HTTP/1.1
Accept: application/xhtml+xml
<html>
... <a rel=”owner” href=”/player/1001”>...</a> ...
<ul class=”moves”>
<li><image src=”/position/initial.png”/></li>
</ul>
</html>
Semantic Web is not a dream
47. Tim Berners-Lee
on Linked Data
“... almost 20 years ago I wanted
to reframe the way we use
informations ... I invented the
Word Wide Web ... now is time
for a new reframing...”
Tim Berners-Lee @ http://linkeddata.org
48. expected behavior of the web
1. Use URIs as names for things
2. Use HTTP URIs so that people
can look up those names
3. When someone looks up a URI,
provide useful information
4. Include links to other URIs, so
that they can discover more things
49. POST /game/42 HTTP/1.1
Content-Type: application/vnd.dharma.chess
Authorization: Basic dXN1cm5hbWU6cG...
n
<game>
<player>...</player>
<moves>
<position>/position/initial</position>
<position color=”white”>
/position/wra1,wna2,...,wpd4,...
</position>
</moves>
</game>
... from and to the Client
51. POST /game/42 HTTP/1.1
Content-Type: application/vnd.dharma.chess
Authorization: Basic dXN1...
n
<game>
<player>...</player>
<moves>
<position>/position/initial</position>
<position color=”white”>
/position/wra1,wna2,...,wpd4,...
</position>
</moves>
</game>
white Player make first move
52. HTTP/1.1 201 Created
Location: /game/42/position/2
Response to the white Player
GET /game/42/position/2
HTTP/1.1 301 Moved Permanently
Location: /position/wra1,wna2,...,wpd4,...
53. GET /game/42 HTTP/1.1
Authorization: Basic dXN1...
n
<game>
<player>...</player>
<moves>...</player>
</game>
GET /game/42 HTTP/1.1
Authorization: Basic aYR5...
n
<game>
<player>...</player>
<moves>...</player>
</game>
both Players must GET
the game Representation
54. POST /game/42 HTTP/1.1
Content-Type: application/vnd.dharma.chess
Authorization: Basic aYR5...
n
<game>
<player>...</player>
<moves>
<position>/position/initial</position>
<position>/position/wra1,wna2,...,wpd4,...</position>
<position color=”black”>
/position/wra1,wna2,...,bpd5,...
</position>
</moves>
</game>
black Player can make next move
55. POST /game/42 HTTP/1.1
Content-Type: application/vnd.dharma.chess
Authorization: Basic aYR5...
n
...
what if black Player try to resend?
HTTP/1.1 409 Conflict
the game Representation is
out of date
56. POST /game/42 HTTP/1.1
Content-Type: application/vnd.dharma.chess
Authorization: Basic aYR5...
n
...
what if black Player try to move again?
HTTP/1.1 403 Forbidden
the black Player should wait
for the white Player to move
57. POST /position/wqd3,wkd1,bke8 HTTP/1.1
n
move = d3-e8
what if we try to make a wrong move?
HTTP/1.1 404 Not Found
Business Rules could be easily
expressed through the Resource's
Behavior
62. FAQ: cool URIs
are RESTful?
OpenSocial
/people/{guid}/@all
Collection of all people connected to user {guid}
http://www.opensocial.org/Technical-Resources/opensocial-spec-v081/restful-protocol.html
63. FAQ: REST is
stateless?
Statelessness says that
all possible states of the server
are also Resources
(Resource State)
64. FAQ: REST is
stateless?
Statelessness says that
each message contains
all the informations necessary
to understand the Request
(Application State)