applied rest - · pdf filerpc-based w eb services are mythically ... what makes soap...

62
Applied REST Brian Sletten Bosatsu Consulting, Inc. [email protected]

Upload: truongtram

Post on 18-Mar-2018

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

AppliedREST

Brian SlettenBosatsu Consulting, Inc.

[email protected]

Page 2: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Over 13 years of software development experience

Has own software consulting company for design, mentoring, training and development

Currently working in Semantic Web, AOP, Grid Computing, P2P and security consulting

Speaker Qualifications

2

Page 3: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Why Do We Care?REST ConceptsREST ExamplesREST MotivationBuilding RESTful InterfacesConclusion

Agenda

3

Page 4: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Why DoWe Care?

Page 5: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

“Conventional” Web Services are often too difficult for non-trivial tasks (real complexity)

too complex for trivial tasks (artificial complexity)

RPC-based Web Services are mythically interoperable and time/process coupled in painful ways

WS-Dissatisfaction

5

Page 6: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

What Makes SOAP Difficult?

Will the real SOAP intended use please stand up?

Remote Procedure Calls

Application Protocols

Tunneling using existing Application Protocols (HTTP)

6

Page 7: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Security Abominations

Tunneling SOAP through firewalls is a questionable practice

HTTP is not a transport protocol!

Intermediaries can only route to endpointsNo actionable semantics in RPC interactions

7

Page 8: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

SOA

Service-Oriented Architecture (SOA)An architectural style promoting loose

coupling among software participantsCompanies have rigid definitions of what

constitutes a SOAMust Publish/Find/Bind = UDDI/WSDL/SOAP?

8

Page 9: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

SOAP 1.2 and Doc Lit are improvements, but are they necessary?

What is the problem we are trying to solve?We already have an example of a scalable

software architecture for network applications

SOA What?

9

Page 10: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Vendors are fineHowever, too many are trying to sell you the same thing repackaged without thinking about what we are trying to solve

CORBA ORB and tools ✘

EJB Container ✘

SOA-complexity managing tools ✔

Return of the Vendors

10

Page 11: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

If You Build It...

...they will use RESTAnecdotally, 85% of Amazon’s users choose REST over SOAP

11

Page 12: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

RESTConcepts

Page 13: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

What is REST?

REpresentational State Transfer (REST)An architectural style based on certain

constraints designed to elicit properties of scalability and extensibility

An idealized notion of how the early Web should work

Helped drive the way it eventually did work

More than just URLs!

13

Page 14: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Anything that can be named/referred toFiles

Services

Concepts

What is returned can change over timeConsider the “trunk” version of a file in Subversion

Resource

14

Page 15: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Generality by allowing different typesStatic or Dynamic

Flexibility through late binding negotiation of type

Abstract references that do not necessarily need updating when the underlying format changes

GIF->PNG

Resource Abstraction

15

Page 16: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Means of naming a resourceStandard syntax that allows various schemesKnown as URIs (or IRIs)Orthogonal to satisfying the referenceOne of the main missing pieces of “normal”

web services

Resource Identifier

16

Page 17: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

A particular deferencing of a Resource Identifier to a Resource at a particular time

Think the file “index.html” or

“Today’s Slashdot Page”

A byte-stream tagged with metadataCould change based on request or

processing/display capabilities of clientFirefox vs. WAP

Representation

17

Page 18: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Accompanies a RepresentationAllows intermediaries to make decisions (caching)

Helps clients know how to display the Resource

IncludesMIME Type

Last modified date

Resource/Representation Metadata

18

Page 19: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

REST Verbs

Design decision to minimize the breadth of the interface

RPC is completely open-ended from an action perspective

19

Page 20: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

GET

Retrieve a Resource

20

Page 21: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

POST

Create a Resource

21

Page 22: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

PUT

Update a Resource

22

Page 23: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

DELETE

Remove a Resource

23

Page 24: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

RESTExamples

Page 25: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

All of these web servers can certainly expose RESTful interfaces

Once you look under the hood, however, it becomes more complicated

Why Not Apache? Tomcat? IIS? Jetty?

25

Page 26: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

NetKernel

Ground up generalized architecture built around REST

Microkernel maps requests for resources into the software components that will satisfy the requests

Benefits from the architectural properties we have discussed

26

Page 27: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

RESTlet

Lightweight Java-based REST frameworkAlternative API to Servlets for cleaner match

to REST conceptsSupport for filters, authentication logging,

blocking and non-blocking IO

27

Page 28: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

RESTMotivation

Page 29: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Concepts are based on Roy Fielding’s work- On his Ph.D. Thesis “Architectural Styles and the Design of Network-based Software Architectures”

- On HTTP 1.0/1.1 Standards

- On Apache, libwww and related projects

The REST is History

29

Page 30: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Software Architecture

30

“A software architecture is defined by a configuration of architectural elements —

components, connectors, and data —constrained in their relationships in order to

achieve a desired set of architectural properties.”

-- R.F. Thesis

Page 31: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Architectural Style

31

“An architectural style is a coordinated set of architectural constraints that restricts the

roles/features of architectural elements and the allowed relationships among those elements within any architecture that

conforms to that style.”

-- R.F. Thesis

Page 32: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Architectural Effects

Choice of a particular architectural style has consequences for how components communicate

Affects overall growth potential and performance of a system

32

Page 33: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Architectural Properties Of Interest

PerformanceScalabilityGeneralitySimplicityModifiability

33

Page 34: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

REST Goals

Provide architectural guidanceMinimize latency of network software

applicationsMaximize component independence and

scalabilitySupport extensibility through small, well-

defined abstract interfaces

34

Page 35: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Supports Separation of Concerns (SOC)UI code can be localized in clientBackend logic can be localized in server

(reused by different clients)

Client-Server

35

Page 36: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Client-Server

36

Page 37: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

All parameters travel with requestNo session information maintained on serverImproves scalability through load-balancingImproves visibility of intermediary processors

Stateless

37

Page 38: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Stateless Client-Server

38

Page 39: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Decentralization of dataCan be wholly or partially copied aroundImproves accessibility and scalabilityImproves user perception of performanceIntroduces need to keep data in synch

Replication

39

Page 40: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Form of replication when external data set is too large to copy locally

Results of individual requests can be captured and re-served later

Cache

40

Page 41: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Improves generality, simplicity and reusabilityCan cause performance issues when data

needs conversion to/from standard formats but REST tries to optimize for average Web data types

Uniform Interface

41

Page 42: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Stateless Client-Server w/ Cache and Uniform Interface

42

Page 43: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Managed dependencies between layersImproved modifiability by compartmentalizing

visibility to neighboring layers

Layered System

43

Page 44: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Layered Stateless Client-Server w/ Cache and Uniform Interface

44

Page 45: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

REST Properties

45

Based on figure from R.F.’s thesis

Page 46: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

BuildingRESTful

Interfaces

Page 47: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

What is Controversial

47

URI OpacityHow much meaning should there be in

URIs?How do naming schemes

affect intermediary processing?make the Web brittle?differ by language context?

Page 48: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

tbl on URI Opacity

48

“When you are not dereferencing you should not look at the

contents of the URI string to gain other information.”

http://www.w3.org/DesignIssues/Axioms.html

http://www.flickr.com/photos/ajstarks/152558066/

Page 49: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Roy on URI Opacity

49

"REST does not require that a URI be opaque. The only place where the word opaque occurs in my dissertation is where I complain about the opaqueness of cookies. In fact, RESTful applications are, at all times, encouraged to use human-meaningful, hierarchical identifiers in order to maximize the serendipitous use of the information beyond what is anticipated by the original application."

http://tech.groups.yahoo.com/group/rest-discuss/message/3232

Page 50: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

UnREST

50

REST is largely defined by a small number of semi-formal specifications, a larger number of secondary publications and writings, and the collected design notes, anecdotes, and essays of Tim Berners-Lee. Among these artifacts there are a number of contradictions, a number of ambiguities, and perhaps at least some assertions and principles which are not sufficiently supported. Where certain

principles and assertions can be formalized and their observable impact quantifiably understood, REST is solid...

My beef with the Opacity Axiom (hereafter, "the axiom") is that it (needlessly, IMHO) discards the important and useful concept of structured naming and semantically rich namespaces. In filesystems research and elsewhere over the last decade or two (described in slightly more detail in OpacityReconsidered) many researchers

have recognized the power and utility gained by enriching the structure and semantics of names and namespaces. The Web, curiously, runs absolutely counter

to this trend.

--Jeff Bone

(http://rest.blueoxen.net/cgi-bin/wiki.pl?OpacityMythsDebunked)

Page 51: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Encoding Meaning in Structure

Which is more meaningful? (To Whom?)http://www.bosatsu.net/talks/NFJS/2006/REST

http://www.bosatsu.net/12123125231234123412

51

Page 52: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Hierarchies

52

http://www.bosatsu.net/talks/NFJS/2006/REST

Organizational

TemporalTopical ?

Page 53: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Hierarchical + Non-Hierchical

53

http://www.bosatsu.net/talks/NFJS/2006/REST/Reston

Organizational

TemporalTopical ?

Page 55: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Pragmatic REST

At a minimum, URIs must be able to be treated opaquely

Hierarchical spaces are conveniently represented through the path portion of a URI

Non-hierarchical attributes should be delegated to the query parameters

55

Page 56: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Do not rely on sessions or other state at the application level

Use nouns, not verbsDon’t abuse GET!No side effects

Don’t abuse POST!Limit use to creation, not conversational GET

What Isn’t Controversial

56

Page 58: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Conclusion

Page 59: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

Describing RESTful services to clientsPublishing metadata about RESTful servicesTransactionsConversational State

Open Issues

59

Page 60: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

REST may not be the only answer, but it is often the more straightforward answer

REST is more than using URLs to access web services

It is the deliberate application of architectural constraints to elicit the properties of scalability, simplicity, modifiability, generality and performance

Main Points

60

Page 61: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

REST started off as the idealized notion for a scalable network software application architectural style

It has become the architectural style of the Web

Software built around REST principles demonstrates similar characteristics (NetKernel)

Nothing necessarily to buy, not a steep learning curve

Selling REST

61

Page 62: Applied REST - · PDF fileRPC-based W eb Services are mythically ... What Makes SOAP Difficult? Will the real SOAP intended use please stand up? Remote Procedure ... scalability and

References

62

Resource Location

Roy Fielding’s Thesis http://tinyurl.com/cvamh

RESTWiki http://tinyurl.com/om38p

Paul Prescod’s REST Thoughts http://www.prescod.net/rest/

NetKernel http://www.1060.org

RESTlet http://www.restlet.org

Flickr Hammock Picture http://tinyurl.com/ehc7j