Modified REST Presentation

35
REpresentational State Transfer Alexandros Marinos [email protected]

description

OPAALS Comp/Soc meeting day 4

Transcript of Modified REST Presentation

Page 1: Modified REST Presentation

REpresentational State TransferREpresentational State Transfer

Alexandros Marinos

[email protected]

Alexandros Marinos

[email protected]

Page 2: Modified REST Presentation

I read way too much…I read way too much…

2

Page 3: Modified REST Presentation

Social Resource ConsumptionSocial Resource Consumption

• I consume content by a lot of sources, in many formats. (Web, Feeds, YouTube, Amazon, Flickr, etc.)

• I share things I find interesting by exposing a Feed, through Google Reader, Facebook, and FriendFeed.

• The people who read my feed may share the content with their contacts as well.

• I consume content by a lot of sources, in many formats. (Web, Feeds, YouTube, Amazon, Flickr, etc.)

• I share things I find interesting by exposing a Feed, through Google Reader, Facebook, and FriendFeed.

• The people who read my feed may share the content with their contacts as well.

3

Page 4: Modified REST Presentation

http://friendfeed.com/alexandroshttp://friendfeed.com/alexandros

4

Page 5: Modified REST Presentation

5

Disambiguating SOADisambiguating SOA

SOA

REST WS-*

SOAPWSDLUDDI

WS - ...

HTTPURIXML

...

SOA

REST WS-*

SOAPWSDLUDDI

WS - ...

HTTPURIXML

...

Page 6: Modified REST Presentation

Disambiguating SOADisambiguating SOA• We have two competing styles, arising from

different areas of practice.

• To make an oversimplification:– WS-* started as enterprise technologies and

attempts to scale to the web

(Previously: CORBA)

– REST started as web technologies and claims to be able to satisfy enterprise requirements

• We have two competing styles, arising from different areas of practice.

• To make an oversimplification:– WS-* started as enterprise technologies and

attempts to scale to the web

(Previously: CORBA)

– REST started as web technologies and claims to be able to satisfy enterprise requirements

6

Page 7: Modified REST Presentation

Disambiguating SOADisambiguating SOA

• Other Contrasts:

– Top-Down vs. Bottom-Up

– Resource-orientation vs. Endpoint-Orientation• Again, Enterprise vs. web origins.

• Other Contrasts:

– Top-Down vs. Bottom-Up

– Resource-orientation vs. Endpoint-Orientation• Again, Enterprise vs. web origins.

7

Page 8: Modified REST Presentation

What is REST Not?What is REST Not?

• REST is agnostic to the underlying network architecture (P2P or Client-Server).

• It is only concerned with the interface that services expose and are accessed through.

• REST is agnostic to the underlying network architecture (P2P or Client-Server).

• It is only concerned with the interface that services expose and are accessed through.

8

Page 9: Modified REST Presentation

What is REST?What is REST?

• An Architectural Style (Such as RPC), Essentially a set of principles.

• A way to decompose an application into smaller parts, so that the whole works better in a distributed setting.

• A proven design pattern for building loosely-coupled, highly-scalable applications.

• An Architectural Style (Such as RPC), Essentially a set of principles.

• A way to decompose an application into smaller parts, so that the whole works better in a distributed setting.

• A proven design pattern for building loosely-coupled, highly-scalable applications.

9

Page 10: Modified REST Presentation

A Little REST MagicA Little REST Magic

Enter this in your browser:

http://www.youtube.com/user/openmicman

Enter this in your browser:

http://www.youtube.com/user/openmicman

10

Page 11: Modified REST Presentation

A Little REST MagicA Little REST Magic

Now, try this:

http://gdata.youtube.com/feeds/users/openmicman

Now, try this:

http://gdata.youtube.com/feeds/users/openmicman

11

Page 12: Modified REST Presentation

Key REST PrinciplesKey REST Principles

• Give every “thing” an ID

• Link things together

• Use standard methods

• Communicate statelessly

• Give every “thing” an ID

• Link things together

• Use standard methods

• Communicate statelessly

12

Page 13: Modified REST Presentation

Give every “thing” an IDGive every “thing” an ID

http://gdata.youtube.com/feeds/users/openmicman

http://gdata.youtube.com/feeds/users/openmicman/favorites

http://www.youtube.com/watch?v=6aKe5baPJCQ

http://gdata.youtube.com/feeds/users/openmicman

http://gdata.youtube.com/feeds/users/openmicman/favorites

http://www.youtube.com/watch?v=6aKe5baPJCQ

13

Page 14: Modified REST Presentation

Link things togetherLink things together

<order self='http://example.com/customers/1234' > <amount>23</amount> <product ref='http://example.com/products/4554' /> <customer ref='http://example.com/customers/1234' />

</order>

<order self='http://example.com/customers/1234' > <amount>23</amount> <product ref='http://example.com/products/4554' /> <customer ref='http://example.com/customers/1234' />

</order>

14

Page 15: Modified REST Presentation

Use standard methodsUse standard methods

• GET– Properties: Safe, Idempotent– Usage: Retrieving a resource

• PUT– Properties: Idempotent– Usage: Creating or updating a resource at a known URI

• DELETE– Properties: Idempotent– Usage: Deleting a resource

• POST– Properties: UNSAFE– Creating a resource within a collection (URI set by server)

• GET– Properties: Safe, Idempotent– Usage: Retrieving a resource

• PUT– Properties: Idempotent– Usage: Creating or updating a resource at a known URI

• DELETE– Properties: Idempotent– Usage: Deleting a resource

• POST– Properties: UNSAFE– Creating a resource within a collection (URI set by server)

15

Page 16: Modified REST Presentation

Example: WS-StyleExample: WS-Style

16

Page 17: Modified REST Presentation

Example: REST-StyleExample: REST-Style

17

Page 18: Modified REST Presentation

Communicate statelesslyCommunicate statelessly

• REST mandates that state be either turned into resource state, or kept on the client.

• Reduces burden on the server

• Reduces coupling with a specific machine

• REST mandates that state be either turned into resource state, or kept on the client.

• Reduces burden on the server

• Reduces coupling with a specific machine

18

Page 19: Modified REST Presentation

Suitability for Mobile Devices

Suitability for Mobile Devices

• By using REST over HTTP instead of SOAP, we can drastically reduce the overhead of message processing

• An HTTP server implementation is feasible for a mobile device

http://opensource.nokia.com/projects/mobile-web-server/

• By using REST over HTTP instead of SOAP, we can drastically reduce the overhead of message processing

• An HTTP server implementation is feasible for a mobile device

http://opensource.nokia.com/projects/mobile-web-server/

19

Page 20: Modified REST Presentation

Who is using REST?Who is using REST?

• Google– GData, OpenSocial

• Standards– Atom, WebDAV

• Amazon– S3, SimpleDB

• Microsoft (!)– Project Astoria, Web3S

• Um… the Web.

• Google– GData, OpenSocial

• Standards– Atom, WebDAV

• Amazon– S3, SimpleDB

• Microsoft (!)– Project Astoria, Web3S

• Um… the Web.

20

Page 21: Modified REST Presentation

REST ResourcesREST Resources

• RESTful Web Services (2007) – Leonard Richardson and Sam Ruby – O’Reilly

• Roy T. Fielding‘s PhD Thesis: “Architectural Styles and the Design of Network-Based Software Architectures”

• A Brief Introduction to REST by Stefan Tilkov

http://www.infoq.com/articles/rest-introduction

• RESTful Web Services (2007) – Leonard Richardson and Sam Ruby – O’Reilly

• Roy T. Fielding‘s PhD Thesis: “Architectural Styles and the Design of Network-Based Software Architectures”

• A Brief Introduction to REST by Stefan Tilkov

http://www.infoq.com/articles/rest-introduction

21

Page 22: Modified REST Presentation

An IdeaAn Idea

• Many of us use web applications (Feed Readers, Photo Sharing, Social Bookmaring, Lifestreaming)

• Therefore we are sharing feeds of various things (Articles, Photos, Favourites, Status Updates)

• That is a lot of data on a bottom-up knowledge space that is forming.

• Many of us use web applications (Feed Readers, Photo Sharing, Social Bookmaring, Lifestreaming)

• Therefore we are sharing feeds of various things (Articles, Photos, Favourites, Status Updates)

• That is a lot of data on a bottom-up knowledge space that is forming.

22

Page 23: Modified REST Presentation

An IdeaAn Idea

• It would be interesting to learn what these feeds are

• Resources will reoccur or propagate from feed to feed

• this may form patterns which may be interesting from a practical or theoretical point of view

• It would be interesting to learn what these feeds are

• Resources will reoccur or propagate from feed to feed

• this may form patterns which may be interesting from a practical or theoretical point of view

23

Page 24: Modified REST Presentation

24

Questions?Questions?

Page 25: Modified REST Presentation

AtomAtom

• Atom Syndication Format– A Feed specification based on RSS 2.0

• Atom Publishing Protocol– a simple HTTP-based protocol for creating and

updating web resources.

• Atom Syndication Format– A Feed specification based on RSS 2.0

• Atom Publishing Protocol– a simple HTTP-based protocol for creating and

updating web resources.

25

Page 26: Modified REST Presentation

Google OpenSocialGoogle OpenSocial

• Open Competitor to Facebook’s Application Platform

• Exposes Three RESTful APIs:– People and Friends data API– Activities data API– Persistence data API

• Open Competitor to Facebook’s Application Platform

• Exposes Three RESTful APIs:– People and Friends data API– Activities data API– Persistence data API

26

Page 27: Modified REST Presentation

SOA?SOA?

• If this sounds like SOA, where are the WSDL, SOAP, UDDI in all this?

• This scenario is actually based on HTTP, RSS, Atom, XML and URI.

• There is more than one way to do SOA

• If this sounds like SOA, where are the WSDL, SOAP, UDDI in all this?

• This scenario is actually based on HTTP, RSS, Atom, XML and URI.

• There is more than one way to do SOA

27

Page 28: Modified REST Presentation

Disambiguating SOADisambiguating SOA

• Business Architecture?

• SOA!

• Technical Architectural Style?

• SOA!

• And what do we implement it with?

• Web Services!

• Business Architecture?

• SOA!

• Technical Architectural Style?

• SOA!

• And what do we implement it with?

• Web Services!

28

Page 29: Modified REST Presentation

Disambiguating SOADisambiguating SOA

• Business Architecture?– SOA

• Technical Architectural Style?– RPC

• Implementation?– WS-* Stack

(SOAP, WSDL, UDDI, WS-…)

http://en.wikipedia.org/wiki/WS-*

• Business Architecture?– SOA

• Technical Architectural Style?– RPC

• Implementation?– WS-* Stack

(SOAP, WSDL, UDDI, WS-…)

http://en.wikipedia.org/wiki/WS-*

29

Page 30: Modified REST Presentation

Disambiguating SOADisambiguating SOA

• Business Architecture?– SOA.

• Technical Architectural Style?– REST

• Implementation?– HTTP, URI, XML

• Business Architecture?– SOA.

• Technical Architectural Style?– REST

• Implementation?– HTTP, URI, XML

30

Page 31: Modified REST Presentation

31

REST ConstraintsREST Constraints

REST has four architectural constraints:• separation of resource from representation, • uniform interface, • self-descriptive messages, and • hypermedia as the engine of application state.

(http://www.stucharlton.com/blog/archives/000141.html )

REST has four architectural constraints:• separation of resource from representation, • uniform interface, • self-descriptive messages, and • hypermedia as the engine of application state.

(http://www.stucharlton.com/blog/archives/000141.html )

Page 32: Modified REST Presentation

32

Resource Oriented Architecture?Resource Oriented Architecture?

• ROA is the term for REST on HTTP/URI

• A Service consists of all the resources available within a certain domain of control

• Since REST is a type of SOA, ROA is an implementation of SOA as well.

• ROA is the term for REST on HTTP/URI

• A Service consists of all the resources available within a certain domain of control

• Since REST is a type of SOA, ROA is an implementation of SOA as well.

Page 33: Modified REST Presentation

33

RESTREST• Important ‘things’ (nouns) are Resources

– Addressed through a URI

• Uniform interface (verbs)– In HTTP: GET, PUT, POST, DELETE

• Verb-noun seperation makes integration easier– GET /customer/45

Instead of getCustomer(45) OR viewCustomer(45) OR showCustomer(45)

• Important ‘things’ (nouns) are Resources– Addressed through a URI

• Uniform interface (verbs)– In HTTP: GET, PUT, POST, DELETE

• Verb-noun seperation makes integration easier– GET /customer/45

Instead of getCustomer(45) OR viewCustomer(45) OR showCustomer(45)

Page 34: Modified REST Presentation

34

HTTP VerbsHTTP Verbs• GET

– Properties: Safe, Idempotent– Usage: Retrieving a resource

• POST– Properties: UNSAFE– Creating a resource within a collection (resource URI unknown)

• PUT– Properties: Idempotent– Usage: Creating or updating a resource at a known URI

• DELETE– Properties: Idempotent– Usage: Deleting a resource

• GET– Properties: Safe, Idempotent– Usage: Retrieving a resource

• POST– Properties: UNSAFE– Creating a resource within a collection (resource URI unknown)

• PUT– Properties: Idempotent– Usage: Creating or updating a resource at a known URI

• DELETE– Properties: Idempotent– Usage: Deleting a resource

Page 35: Modified REST Presentation

Give every “thing” an IDGive every “thing” an ID

Resources are not only represented as XML

• XML formats (HTML, XHTML, RSS, etc.)• JPG, GIF, PNG• MP3, WAV, OGG• Anything else that can be on the web.

• Thomas: maybe Resources = Knowledge Services?

Resources are not only represented as XML

• XML formats (HTML, XHTML, RSS, etc.)• JPG, GIF, PNG• MP3, WAV, OGG• Anything else that can be on the web.

• Thomas: maybe Resources = Knowledge Services?

35