Web API HTTP Pipeline
Description
Understand the client-side and server-side Web API HTTP Pipelines.
Shared by: LearnNowOnline
Categories
Tags
-
Stats
- views:
- 17
- posted:
- 10/10/2012
- language:
- English
- pages:
- 22
Document Sample


Web API HTTP Pipeline
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
Objectives
• Understand the client-side and server-side
pipelines
• Send the best HTTP responses for Web API
operations
• Use the HTTP pipeline objects to handle
exceptions
• Write your own custom handlers for Web API
requests
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
Agenda
• Pipeline Elements
• Client-Side Pipeline
• Server-Side Pipeline
• Improving CRUD Responses
• Exception Handling
• Custom Handlers
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
Pipeline Elements
• Request/Response models have pipelines
• Composed of sequential events that fire
• Uses specific objects
• Web API has client and server-side pipelines
• Both share some common objects
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
HttpRequestMessage
• Represents all the info about the HTTP request
• URL
• HTTP method
• Headers
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
HttpResponseMessage
• Represents all the info about the HTTP
response
• Status code
• Success flag
• Original HTTP request
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
HttpMessageHandler
• Base class implemented by other objects
• Most custom processing code goes here
• Able to write custom handlers and put them in
the pipeline
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
Agenda
• Pipeline Elements
• Client-Side Pipeline
• Server-Side Pipeline
• Improving CRUD Responses
• Exception Handling
• Custom Handlers
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
Client-Side Pipeline
• HttpClient sends requests
• Request is an HttpRequestMessage
• Request is sent to HttpMessageHandler
• HttpMessageHandler returns
HttpResponseMessage
• Default handler is HttpClientHandler
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
Client-Side Pipeline
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
Agenda
• Pipeline Elements
• Client-Side Pipeline
• Server-Side Pipeline
• Improving CRUD Responses
• Exception Handling
• Custom Handlers
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
Server-Side Pipeline
• Web host gives the request to HttpServer
• Request passed through series of
HttpMessageHandlers
• Ends with HttpControllerDispatcher
• Dispatcher sends request to appropriate
Controller which sends response
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
Agenda
• Pipeline Elements
• Client-Side Pipeline
• Server-Side Pipeline
• Improving CRUD Responses
• Exception Handling
• Custom Handlers
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
Improving CRUD Responses
• By default, Web API always sends same HTTP
response code
• Can alter the response to include more
accurate info
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
Improving CRUD Responses
• Let’s improve a Web API service’s HTTP
responses!
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
Agenda
• Pipeline Elements
• Client-Side Pipeline
• Server-Side Pipeline
• Improving CRUD Responses
• Exception Handling
• Custom Handlers
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
Exception Handling
• Exceptions tend to be vague on client
• HttpResponseException
• Can use filters to assign HTTP responses
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
Exception Handling
• Let’s set up an automated way to send better
error messages to the client
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
Agenda
• Pipeline Elements
• Client-Side Pipeline
• Server-Side Pipeline
• Improving CRUD Responses
• Exception Handling
• Custom Handlers
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
Custom Handlers
• Inherit DelegatingHandler
• Custom code to perform any kind of per
request functionality
• Logging
• Security
• Handling certain kinds of requests
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
Custom Handlers
• We’ll add some security to a Web API service
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
Learn More!
• This is an excerpt from a larger course. Visit
www.learnnowonline.com for the full details!
• Learn more about Web API on SlideShare:
Web API Basics
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
Get documents about "