1 RESTful Services a la carte Gustavo Javier
- Slides: 38
1
RESTful Services ‘a la carte’ Gustavo Javier Machado Architect Tellago Inc. gustavo. machado@tellago. com http: //thegsharp. wordpress. com 2
Agenda REST & Microsoft WCF Web. Http WCF Data. Services MVC 2 When to use what? 3
REST
REST WHAT REST STANDS FOR? Representational State Transfer. WHAT IS IT? Architecture style WHY REST? • Better use of HTTP • Less complexity • Better interoperability 5
REST - Principles § IDENTIFY RESOURCES WITH URIS § USE HTTP VERBS § LINK RESOURCES § PRESENT IN MULTIPLE FORMATS (XML, JSON, ETC) §STATELESS COMMUNICATION 6
REST – Principle 1 “IDENTIFY RESOURCES WITH URIS” Examples: HTTP: //MYSERVICE/ROOMS/3 HTTP: //MYSERVICE/COLORS/RED HTTP: //MYSERVICE/TRANSACTION/1145001
REST – Principle 2 “USE • • HTTP VERBS” GET: Returns a representation of the resource PUT: Updates the resource POST: Creates a resource DELETE: Deletes a resource
REST – Principle 3 “LINK RESOURCES” <order self=’http: //example. com/orders/1234’> <amount>23</amount> <product ref=’http: //example. com/products/4554’ /> <customer ref=’http: //example. com/customers/1234’ /> </order>
REST – Principio 4 “PRESENT IN MULTIPLE FORMATS” GET /accounts('UBS') Host: restsamples. com Accept: application/atom+xml … GET /accounts('UBS') Host: restsamples. com Accept: application/json …
REST – Principio 5 “STATELESS COMMUNICATION” GET /accounts('ubs') Host: restsamples. com Accept: application/account+xml <account><contact ref="/contacts('ubs-12345')">. . . </contact></account> … GET /contacts('ubs-12345') Host: restsamples. com Accept: application/contact+xml <contact id="ubs-12345">. . . </contact>
RESTfulness SOAPers vs RESTafaris
Microsoft & REST
Microsoft & REST
Microsoft y REST WCF WEBHTTP XML JSON Atom Public class Service: IContract { [Web. Get] Type Operation 1(parameters…. ); . . . [Web. Invoke] Type Operationn(parameters…. ); }
Microsoft y REST WCF DATASERVICES GAVE US ODATA Atom. P JSON Public class My. Context : IUpdatable { IQueryable<T 1> field 1; . . . IQueryable<Tn> fieldn; }
Microsoft y REST AND LET’S NOT FORGET ABOUT ASP. NET MVC XML JSON Atom Public class Service : Controller { Action. Result Action 1(parameters…); . . . Action. Result Actionn(parameters…);
WCF Web. Http
WCF Webhttp WCF PROGRAMMING MODEL. PROVIDES GREATER CONTROL OVER URIS, FORMATS Y PROTOCOLS. WEB SERVICES OVER HTTP, RESTFUL OR NOT. 19
WCF Webhttp. NET 3. 5 DOWNLOAD WCF REST STARTER KIT (CODEPLEX). IMPORT MICROSOFT. HTTP Y MICROSOFT. HTTP. EXTENSIONS DLLS. . NET 4. 0 MOST OF THE CLASSES ARE IN SYSTEM. SERVICEMODEL. WEB. FOR REST CLIENTS WE CAN USE THE WCF REST STARTER KIT. 20
HELLO WORLD! EL REQUEST… (GET) http: //myservice/Greetings/Gustavo EL RESPONSE <string xmlns="http: //schemas. microsoft. com/2003/10/Ser ialization/">Hello Gustavo</string>
CODE… Uri template Http Verb Help page Format Links Error codes 22
Questions… 23
WCF Data. Services 24
WCF Dataservices IF WE WENT FROM OUR CRUD INTERFACE, TO A GENERIC ONE… … WE’D BE DEFINING A REST PROTOCOL FOR CRUD SERVICES… OR WE COULD JUST USE ATOMPUB INSTEAD… 25
WCF Dataservices … AND IF WE COULD EXPOSE IQUERYABLE<T> MEMBERS IN A RESTFUL WAY… …WE WOULD BE DEFINING OUR OWN PROTOCOL FOR QUERYING. . . AND IF WE COMBINE ATOMPUB WITH OUR NEW PROTOCOL WE GET… 26
WCF Dataservices ODATA Atom. P JSON 27 Public class My. Context : IUpdatable { IQueryable<T 1> field 1; . . . IQueryable<Tn> fieldn; }
WCF Dataservices Public class My. Context : IUpdatable {. } 28
CODIGO… Custom Container EF client/servidor Access. Rules Service Operations 29
ASP. NET MVC 30
ASP. NET MVC XML JSON Atom 31 Public class Service : Controller { Action. Result Action 1(parameters…); . . . Action. Result Actionn(parameters…);
ASP. NET MVC Web Uris Format 32
When to use what? 33
When to use WCF Web. Http If you want… Full control to design operations to expose a SOAP version 34
When to use WCF Dataservice If you want… to expose a Data Model to provide querying capability to abstract DAL from your application 35
When to use ASP. NET MVC If you want… to consume from the client side of a website to provide an HTML version of the resource 36
Gustavo Machado Contact information Gustavo. machado@tellago. com http: //thegsharp. wordpress. com http: //twitter. com/machadogj http: //ar. linkedin. com/in/machadogj 37
© 2008 Microsoft Corporation. Todos los derechos reservados. Microsoft, Windows Vista y otros nombres de producto son y pueden ser marcas registradas y registros en Estados Unidos y en otros países. La información contenida en el presente es sólo para fines informativos y representa la visión actual de Microsoft Corporation a la fecha de esta presentación. Debido a que Microsoft debe responder a las cambiantes condiciones del mercado, no se debe interpretar como un compromiso por parte de Microsoft, y Microsoft no puede garantizar la precisión de ninguna información provista después de la fecha de esta presentación. MICROSOFT NO OFRECE GARANTÍA ALGUNA, EXPRESA, IMPLÍCITA O DE LEY, RESPECTO A LA INFORMACIÓN EN ESTA PRESENTACIÓN. 38
- Javier gustavo oyarse cruz
- La carte service
- Shapes that have smooth even edges and are measurable
- Shapes that have smooth even edges and are measurable
- Restful vs restless
- The way my mother speaks carol ann duffy annotated
- Generally restful like the horizon where the sky meets land
- Gustavo visentini
- Casta esteban navarro
- Josefina espin
- Gustavo cani
- La biografía de gustavo adolfo bécquer
- Gustavo moussalli
- Gesto gustavo
- "dr. gustavo"
- Gustavo ramirez escobar
- Gustavo rojas pinilla
- Lus gustavo
- Esfago
- Gustavo bruni
- Gustavo cancelo
- Gustavo poblete
- Gustavo martnez
- Gustavo gauer
- Gustavo alamón
- Gustavo giovannoni obras
- Cs252 purdue
- Ufmg raquel julia rita carolina
- Gustavo ernesto medina zapata
- Gustavo gauer youtube
- Gustavo vergagni
- Gustavo dallarda
- Biografia de gustavo adolfo becquer
- Gustavo rocha edad
- Gustavo diaz ordaz linea del tiempo
- La corza blanca analisis
- The challenge gustavo
- Lus gustavo
- Gustavo fuchs