260 likes | 416 Views
REST- baserade tjänster med WCF ASP.NET Web API. Robert Folkesson. Active Solution. Who AM I?. REST?. Dissertation by Roy Fielding 2000 “Architectural Styles and the Design of Network-based Software Architectures” ReST = Representational State Transfer. Architectural constraints.
E N D
REST-baseradetjänster med WCF ASP.NET Web API Robert Folkesson Active Solution
REST? • Dissertation by Roy Fielding 2000 • “Architectural Styles and the Design of Network-based Software Architectures” • ReST = Representational State Transfer
Architecturalconstraints • Client–server • Stateless • Cacheable • Layered system • Uniform Interface
Scalability GET http://fabrikam.com/API/User/42
Guiding principles of REST-interfaces • Identificationofresources • Manipulation of resources through representations of these resources • Self-descriptivemessages • Hypermedia as the engine of application state
Richardsons maturitymodel Gloryof REST Level 3: Hypermedia Controls Level 2: HTPP Verbs Level 1: Resources Level 0: The swampof POX
REST on Microsoft – somehistory • WCF pre-3.5: painful… • WCF 3.5: WebHttpBinding. • WCF REST Starter Kit (no longer supported) • WCF Data Services (OData) • WCF Web API - Preview 1 - 6
http://www.asp.net/web-api • Goal: One HTTP/ REST / Hypermedia API Fx • Integrated in ASP.NET: Best ofbothworld
WCF to ASP.NET Web API WCF Web APIASP.NET Web API Service => Web API controller Operation => Action Service contract => n/a Endpoint => n/a URI templates => ASP.NET Routing Messagehandlers => Same Formatters => Same Operation handlers => Filters, modelbinders
Media types & Media Formatters • Built in support for: • XML • JSON • form-urlencodeddata • Can be extendedwithcustomMedia Formatters
Web API on NuGet • Web API hosted in ASP.NET: • AspNetWebApi • Self-hostedWeb API: • AspNetWebApi.Selfhost • HttpClientincluding XML and JSON formatters: • System.Net.Http.Formatting • JsonValuefor navigating and manipulating JSON: • System.JsonNewtonsoft.Json
Node-style Web API? http://blogs.msdn.com/b/youssefm/archive/2012/02/24/writing-a-lightweight-web-service-using-webapi-building-blocks.aspx
Web API can be used for all levels Gloryof REST Level 3: Hypermedia Controls Level 2: HTPP Verbs ASP.NET Web API Level 1: Resources Level 0: The swampof POX
OAuth/Claimsbasedsecurity http://zamd.net/
Thank you! Robert Folkesson | Active Solution robert.folkesson@activesolution.se | @rfolkes www.robertfolkesson.se