Web Services, Web Apps, and REST - GOTO...

Post on 22-May-2020

5 views 0 download

Transcript of Web Services, Web Apps, and REST - GOTO...

Web Services,Web Apps, and REST

Stefan Tilkov, @stilkov | GOTO Copenhagen 2011

1Friday, May 13, 2011

(Personal)History

2Friday, May 13, 2011

Sockets

3Friday, May 13, 2011

RPC

4Friday, May 13, 2011

DCE

5Friday, May 13, 2011

CORBA

6Friday, May 13, 2011

RMI

7Friday, May 13, 2011

MOM

8Friday, May 13, 2011

WS-*

9Friday, May 13, 2011

10Friday, May 13, 2011

“Add the missing parts to the Web”

11Friday, May 13, 2011

REST

12Friday, May 13, 2011

RESTful HTTP

13Friday, May 13, 2011

URIs Identi!es Resources

http://example.com/orders?year=2008

http://example.com/customers/1234

http://example.com/orders/2007/10/776654

http://example.com/products/4554

http://example.com/processes/sal-increase-234

14Friday, May 13, 2011

Resources are Linked

15Friday, May 13, 2011

Representations in di!erent Formats

XML

HTMLXHTML

JSONYAML

Plain Text

PDF

Binary

16Friday, May 13, 2011

Customer

Order

Delivery Product

CustomerList

ProductCatalog

Rating

«interface»Resource

17Friday, May 13, 2011

GETPUT

POSTDELETE

«interface»Resource

18Friday, May 13, 2011

http://www.flickr.com/photos/stygiangloom/230412544/

Tunneling

19Friday, May 13, 2011

(a.k.a. The SOAP Way)

20Friday, May 13, 2011

POST http://example.com/CustomerMgmt<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <deleteCustomer xmlns="http://example.com/ns1"> <customerId>13</customerId> </ns:deleteCustomer> </soap:Body></soap:Envelope>

Method ID Endpoint

21Friday, May 13, 2011

22Friday, May 13, 2011

23Friday, May 13, 2011

24Friday, May 13, 2011

“Thank you for nothing.”

Enterprise Web

"Here are the missing parts of the Web!”

25Friday, May 13, 2011

The Human Web

26Friday, May 13, 2011

27Friday, May 13, 2011

Resources and URIs

Pretty URLs

Bookmarks

Collaboration

Caching

Links/Hypermedia

Noti"cation via Feeds

28Friday, May 13, 2011

Web Sitesvs.

Web Applications

29Friday, May 13, 2011

Using the Webvs.

Abusing the Web

30Friday, May 13, 2011

There should be no applications

31Friday, May 13, 2011

Customer

Order Delivery

ProductCustomerList

ProductCatalog

CustomerView

OrderEntryForm ProductMaintenanceForm

32Friday, May 13, 2011

Customer

Order

Delivery Product

CustomerList

ProductCatalog

Rating

«interface»Resource

CustomerViewOrderEntryForm

ProductMaintenanceForm

33Friday, May 13, 2011

What’s in an app?

34Friday, May 13, 2011

Browser

Server AClient A

Server BClient B

35Friday, May 13, 2011

Browser

Server A

Server B

Client Portal

36Friday, May 13, 2011

37Friday, May 13, 2011

Browser

Server A

Server B

Resource 1

Resource 2

Resource n

Representation 1

Representation 2

Representation n

......

38Friday, May 13, 2011

Web Frameworks of 2001

Hide HTTP, URIs, HTML

Maintain Desktop-app state on server

Tunnel Stateful Apps through the Web

39Friday, May 13, 2011

© 2011 innoQ Deutschland GmbH

JSF Life Cycle

40Friday, May 13, 2011

© 2011 innoQ Deutschland GmbH41Friday, May 13, 2011

© 2011 innoQ Deutschland GmbH

How much HTTP would you like with that?

42Friday, May 13, 2011

© 2011 innoQ Deutschland GmbH

Component-based

JSF

ASP.NET

Wicket

Tapestry

GWT

43Friday, May 13, 2011

© 2011 innoQ Deutschland GmbH

Request/Response-oriented

Struts

PlayGrails

Rails

ASP.NET MVC

PHPDjango

Spring MVC

44Friday, May 13, 2011

© 2011 innoQ Deutschland GmbH

Linkable and “pretty” URIs

GET/POST di!erentiation

Support for caching

Full control over HTML

1 Resource, n Views

Request/Response Frameworks

45Friday, May 13, 2011

“But what about statefulWeb applications?”

46Friday, May 13, 2011

Server

Client 1

Client 2State Client 1

State Client 2

Server State

R1R2

Rn

Representation

R1

R2

Turn session state …

47Friday, May 13, 2011

Server

Client 1

C1 C1

Client 2

C2

State Client 1

State Client 2

Server State

Representation

R1 R2

RnC2

C2

C2

C1C1

R2

R1

… into client or resource state

48Friday, May 13, 2011

Browser Server

HTML Page

Label

Label

Label

Label

Label

Label

Label

Label

Submit

49Friday, May 13, 2011

Browser Server

Label

Label

Label

Next

Label

Label

Label

Next

Label

Label

Finish

SessionState

50Friday, May 13, 2011

Browser

Server

Label

Label

Label

Next

Label

Label

Label

Next

Label

Label

Finish

HTML Page

Label

Label

Label

Label

Label

Label

Label

Label

Submit

Client State

51Friday, May 13, 2011

JavaScript

52Friday, May 13, 2011

JavaScript Perception

“Toy language”

Incompatible

Inherent design problems

Low Performance

53Friday, May 13, 2011

http://commons.wikimedia.org/wiki/File:Audi_S5_V8_FSI_engine.jpg

54Friday, May 13, 2011

55Friday, May 13, 2011

http://commons.wikimedia.org/wiki/File:Ateles_paniscus_-Brazil-8.jpg

56Friday, May 13, 2011

57Friday, May 13, 2011

The JavaScript Arms Race

58Friday, May 13, 2011

59Friday, May 13, 2011

60Friday, May 13, 2011

http://oreilly.com/catalog/9780596517748

61Friday, May 13, 2011

62Friday, May 13, 2011

JavaScript Today

Popular & widely used

O"en mandatory

Fast

Compatible

Best practices

63Friday, May 13, 2011

5.1.7 Code-On-DemandThe final addition to our constraint set for REST comes from the code-on-demand style of Section 3.5.3 (Figure 5-8). REST allows client functionality to be extended by downloading and executing code in the form of applets or scripts. This simplifies clients by reducing the number of features required to be pre-implemented. Allowing features to be downloaded after deployment improves system extensibility. However, it also reduces visibility, and thus is only an optional constraint within REST.

http://www.ics.uci.edu/~!elding/pubs/dissertation/rest_arch_style.htm#sec_5_1_7

64Friday, May 13, 2011

Unobtrusive JavaScript

65Friday, May 13, 2011

<a href="javascript:function1();">Some Link</a>

66Friday, May 13, 2011

<a href="#" onclick="function1();">Some Link</a>

67Friday, May 13, 2011

<a href="/some-resource" onclick="function1(this.href);">Some Link</a>

68Friday, May 13, 2011

<a href="/some-resource" class="whatever">Some Link</a>

69Friday, May 13, 2011

JavaScript

CSSHTML

Content

Behavior

Layout

70Friday, May 13, 2011

Caching

71Friday, May 13, 2011

“I do think the REST-afarians are missing an opportunity by not driving home the secret sauce that is HTTP GET. […] GET is one of the most optimized pieces of distributed systems plumbing in the world.

Don Box, Co-inventor of SOAP

72Friday, May 13, 2011

Cacheable Elements

73Friday, May 13, 2011

Obvious

Static text

Images

CSS

JavaScript

Non-obvious

Menus

Hierarchies

Processing Results

Immutable stu#

74Friday, May 13, 2011

The problem:Personalized dynamic

elements

75Friday, May 13, 2011

76Friday, May 13, 2011

Logout

77Friday, May 13, 2011

Login

78Friday, May 13, 2011

Edge Side Includes (ESI)

79Friday, May 13, 2011

<esi:include src="http://example.com/1.html" alt="http://bak.example.com/2.html" onerror="continue"/>

<esi:include src="http://example.com/search?query=$(QUERY_STRING{query})"/>

80Friday, May 13, 2011

Browser

HTML Page

BackendStatic Cache

Dynamic Dynamic

Static

81Friday, May 13, 2011

Browser

HTML Page

BackendStatic Cache

Dynamic Dynamic

Static

82Friday, May 13, 2011

Ajax

83Friday, May 13, 2011

Browser

HTML Page

BackendStatic Cache

Dynamic Dynamic

Static

84Friday, May 13, 2011

Browser

HTML Page

BackendStatic Cache

Dynamic

Dynamic

Static

85Friday, May 13, 2011

#!

http://www.jenitennison.com/blog/node/154

86Friday, May 13, 2011

#

87Friday, May 13, 2011

#“When a URI reference is used to perform a retrieval action on the identi!ed resource, the optional fragment identi!er, separated from the URI by a crosshatch (“#”) character, consists of additional reference information to be interpreted by the user agent a!er the retrieval action has been successfully completed. As such, it is not part of a URI, but is o"en used in conjunction with a URI.”

URI Speci!cation, August 1998

88Friday, May 13, 2011

#The fragment identi!er component of a URI allows indirect identi"cation of a secondary resource by reference to a primary resource and additional identifying information. The identi!ed secondary resource may be some portion or subset of the primary resource, some view on representations of the primary resource, or some other resource de!ned or described by those representations.

URI Speci!cation, January 2005

89Friday, May 13, 2011

#!

90Friday, May 13, 2011

http://example.com/someapp#!state=234

http://example.com/someapp?_escaped_fragment=234

91Friday, May 13, 2011

http://googlewebmastercentral.blogspot.com/2009/10/proposal-for-making-ajax-crawlable.html

92Friday, May 13, 2011

Complex

Inaccessible

Brittle

Invisible to search engines (#)

# and #! Downsides

93Friday, May 13, 2011

HTML 5

pushState()replaceState()

94Friday, May 13, 2011

Summary

95Friday, May 13, 2011

Embrace the Web,Don't !ght it

96Friday, May 13, 2011

Web UIs !rst,Client apps second

97Friday, May 13, 2011

Don’t repeat server mistakes on the client

98Friday, May 13, 2011

If you can't link to it, does it exist?

99Friday, May 13, 2011

If you can't build real Web apps with it, is it worth your

time?

100Friday, May 13, 2011

Thank you!

Q&A

101Friday, May 13, 2011

Stefan Tilkovstefan.tilkov@innoq.comhttp://www.innoq.com/blog/st/@stilkovPhone: +49 170 471 2625

innoQ Deutschland GmbH innoQ Schweiz GmbH

www.innoq.com info@innoq.com

Halskestr. 17D-40880 RatingenPhone: +49 21 02 77 172-100

Gewerbestr. 11CH-6630 ChamPhone: +41 41 02 743 01 11

102Friday, May 13, 2011