Consultant • Currently with the Service Delivery Broker team (SAPO - Portugal Telecom) • Co-author of Designing Evolvable Web APIs with ASP.NET (to be published in 2013 by O’Reilly) 2
by exchanging messages An HTTP "server" is a program that accepts connections in order to service HTTP requests by sending HTTP responses. In Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing 3 Request Message Response Message ? ASP.NET Web API
and test • Both typed and untyped access to message members (e.g. headers) • Extensible HTTP content class hierarchy • Based on the Task Asynchronous Pattern • Usable on both the client and server sides 12
and response buffering – IHostBufferSelector • TLS client certificate • Uses ASP.NET Routing • To select the ASP.NET IHttpHandlers • To obtain the Web API routing data • Sits on top of the classical ASP.NET pipeline • Connection configuration at IIS 26
Request and response buffering (.TransferMode) • TLS client certificate (.ClientCredentialType) • Timeouts (.ReceiveTimeout) • Throttling (.MaxConcurrentRequests) • Does not perform any routing • Routing is evaluated by the routing message handler • After the common message handlers • Connection configuration via netsh 28
Route Dispatcher Controller Dispatcher Per-Route Handler WCF Generic Service Using WebHttpRelayBinding Service Bus Relay HttpRequestMessage HttpResponseMessage
• Based on model binders and value providers (similar to ASP.NET MVC) • Used to bind from request URI • Related to FromUriAttribute • Multiple parameters • Default for simple types • FormatterParameterBinding • Based on the MediaTypeFormatter concept • Used to bind from request body • Related to FromBodyAttribute • One parameter only • Default for complex types 37
associated representation The indicated media type defines both the data format and how that data is intended to be processed by a recipient In Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content (bolds are mine) • Examples • text/plain, text/html, application/json, application/xml • application/hal+json, application/vnd.collection+json • application/vnd.github+json • See http://www.iana.org/assignments/media-types 39
byte sequence • The MediaTypeFormatter is chosen based on • The CLR object type • The request message, namely • The Accept header • The request URI • Server-driven content negotiation 43
G. Block, P. Cibraro, P. Félix, H. Dierking & D. Miller Designing Evolvable Web APIs with ASP.NET • To be published by O’Reilly in 2013 • Preview available at O’Reilly Atlas - http://chimera.labs.oreilly.com/books/1234000001708 • Samples at https://github.com/pmhsfelix 46