(20.05.2009) Cumuy Presenta - Más tecnologías interesantes para conocer - PPT 1
-
Upload
microsoft-argentina-y-uruguay-official-space -
Category
Documents
-
view
377 -
download
4
description
Transcript of (20.05.2009) Cumuy Presenta - Más tecnologías interesantes para conocer - PPT 1
A N D R É S A G U I A R
A A G U I A R @ I N F R A G I S T I C S . C O M
H T T P : / / W E B L O G S . A S P . N E T / A A G U I A R - @ A A G U I A R
REST y Silverlight 2.0
REST
REST es un patrón de diseño
El término fue creado por Roy Fielding en sudisertación de Ph.D. en el año 2000
http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm
Principio #1
Todo es un RECURSO
Ejemplos:
Clientes
Lugares
Productos
Principio #2
Los Recursos tienen NOMBRES
Ejemplos:
http://acme.com/customers/coyote
http://world.com/usa/california/san_diego
xri://@acme*warehouse/(+rockets)
Principio #3
Los recursos soportan VERBOS simples
Ejemplos:
Create, Read, Update, Delete
POST, GET, PUT, DELETE
Principio #4
Los recursos tienenREPRESENTACIONES
Ejemplos:
HTML: text/html, application/xhtml+xml, …
XML: text/xml, application/atom+xml, …
Binary: image/png, application/pdf, …
REST y HTTP
Get
Obtiene un Resource
Está garantido que no causa side-effects (Safe)
Cacheable
Post
Crea un nuevo recurso
Unsafe, el efecto de este verbo no esta definido por http
REST y HTTP
Put
Actualiza un recurso existente
Se usa para crear recursos si el cliente conoce el Uri
Se puede llamar N veces y pasa lo mismo (idempotente)
Delete
Elimina un recurso
Se puede llamar N veces y pasa lo mismo (idempotente)
REST y HTTP
Simple : basado en pocos principios y operaciones bien definidas
Escalable: se apiya en protocolos „stateless‟ y estado distribuido
En capas: premite cualquier cantidad de intermediarios como proxies, gateways y firewalls
Modelado REST
Escenario: Búsqueda de itinerarios Busco itinerarios
Pido mas información
Reservo un pasaje
interface IFlightSystem
{Itineraries Search(string src, string dest);Details GetDetails(int itineraryId);Confirmation Reserve(itineraryId);
}
http://quuxTravel.com/search?src=London&dest=NYC
<itineraries><itinerary src=“London“ dest=“NYC“ price=“400.03“><getDetails uri=“http://quuxTravel.com/details?itinerary=402“ />
<reserve uri=“http://reservations.com/quuxTravel?itinerary=402“/>
</itinerary>
<itinerary src=“London“ dest=“NYC“ price=“109.88“><getDetails
uri=“http://quuxTravel.com/details?itinerary=219“/><reserve
uri=“http://reservations.com/quuxTravel?itinerary=219“/></itinerary>
</itineraries>
PURE REST
http:/../v1/Recurso/<Id> POST, GET, DELETE, PUT
No:
http:/../v1/Recurso/get/Id
http:/../v1/Recurso?Id=1
http:/../v1/Recurso.svc?Id=1
http:/../v1/Search?q=keyword GET
Content Type
GET /customer/1 HTTP/1.1Accept: application/xml
HTTP/1.1 200 OKContent-Type: application/xml<Customer><Id>1</Id></Customer>
GET /customer/1 HTTP/1.1Accept: text/html
HTTP/1.1 200 OKContent-Type: text/html<html xmlns="http://www.w3.org/1999/xhtml"> ….
GET /customer/1 HTTP/1.1Accept: image/gif
HTTP/1.1 200 OKContent-Type: image/gifGif89a
REST vs „Big Web Services‟
No Caching – HTTP Caching
WSDL vs WADL o /help)
UDDI vs Google Search
HTTPS y HTTP Auth vs WS-Security
WS-Federation vs protocolos abiertos tipo OpenID
WS-Transaction vs Nada
WS-Reliable Messaging vs Nada AtMostOnce, AtLeastOne, ExactlyOnce, InOrder
POST Exactly Once?
REST Pragmático – Lo REST
Usar HTTP + XML como mecanismo de comunicación entre capas
Ventajas: Fácil de usar
Caching, Caching, Caching
Caching
Los GETs se pueden cachear Cache-Control header
“no-cache”
“max-age=Segundos”, por ejemplo, “max-age=60”
Expires header
“Expires: Sat, 26 Jul 1997 05:00:00 GMT”
Pragma: no-cache
Conditional GET
GET /icon-cart.gif HTTP/1.1
HTTP/1.1 200 OKContent-Length: 389Content-Type: image/gifLast-Modified: Fri, 08 Aug 2008 16:19:58 GMT
GET /icon-cart.gif HTTP/1.1If-Modified-Since: Fri, 08 Aug 2008 16:19:58 GMT
HTTP/1.1 304 Not Modified
Conditional GET
GET /icon-cart.gif HTTP/1.1
HTTP/1.1 200 OKContent-Length: 389Content-Type: image/gifETag: "d0afa29638fec81:43a"
GET /icon-cart.gif HTTP/1.1If-None-Match: "d0afa29638fec81:43a“
HTTP/1.1 304 Not Modified
Cache en el Browser
Configuración La copia del cache es nueva
La copia del cache es vieja
No hay directivas de cache
Cada vez que sevisita la página
No hay request RequestCondicional
RequestCondicional
Cada vez que seinicia IE
No hay request RequestCondicional
RequestCondicional
Automática No hay request RequestCondicional
Heurística
Nunca No hay request RequestCondicional
No hay request
Heurística
Todas las siguientes condiciones: El recurso cacheado tiene un Content-Type que empieza con
image/.
El recurso cacheado tiene Last-Modified.
La URL cacheada no tiene un „?‟
“The cached resource has been conditionally requested at least once within the most recent 25 percent of its overall age in the cache”
http://msdn.microsoft.com/en-us/library/aa905731.aspx
Conditional GET
GET /icon-cart.gif HTTP/1.1
HTTP/1.1 200 OKCache-Control: max-age=1Content-Length: 389Content-Type: image/gifLast-Modified: Fri, 08 Aug 2008 16:19:58 GMT
GET /icon-cart.gif HTTP/1.1If-Modified-Since: Fri, 08 Aug 2008 16:19:58 GMT
HTTP/1.1 304 Not Modified
REST in SL
Http Request son asincrónicos
SL 2 no permite leer headers de requests o requestsque retornen <> HTTP 2XX No „304 Not Modified‟
No permite PUT/DELETE
Server REST
Http Handlers
ASP.NET MVC
WCF REST support
GO TO Visual Studio