Web API HTTP Pipeline

1,674 views

Published on

Understand the client-side and server-side Web API HTTP Pipelines.

Published in: Technology
  • Be the first to comment

Web API HTTP Pipeline

  1. 1. Web API HTTP Pipeline Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  2. 2. Objectives Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  3. 3. Objectives• Understand the client-side and server- side pipelines Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  4. 4. Objectives• Understand the client-side and server- side pipelines• Send the best HTTP responses for Web API operations Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  5. 5. 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 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  6. 6. 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
  7. 7. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  8. 8. Agenda• Pipeline Elements Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  9. 9. Agenda• Pipeline Elements• Client-Side Pipeline Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  10. 10. Agenda• Pipeline Elements• Client-Side Pipeline• Server-Side Pipeline Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  11. 11. Agenda• Pipeline Elements• Client-Side Pipeline• Server-Side Pipeline• Improving CRUD Responses Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  12. 12. Agenda• Pipeline Elements• Client-Side Pipeline• Server-Side Pipeline• Improving CRUD Responses• Exception Handling Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  13. 13. 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
  14. 14. Pipeline Elements Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  15. 15. Pipeline Elements• Request/Response models have pipelines Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  16. 16. Pipeline Elements• Request/Response models have pipelines• Composed of sequential events that fire Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  17. 17. Pipeline Elements• Request/Response models have pipelines• Composed of sequential events that fire• Uses specific objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  18. 18. Pipeline Elements• Request/Response models have pipelines• Composed of sequential events that fire• Uses specific objects• Web API has client and server-side pipelines Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  19. 19. HttpRequestMessage Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  20. 20. HttpRequestMessage• Represents all the info about the HTTP request Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  21. 21. HttpRequestMessage• Represents all the info about the HTTP request • URL Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  22. 22. HttpRequestMessage• Represents all the info about the HTTP request • URL • HTTP method Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  23. 23. 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
  24. 24. HttpResponseMessage Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  25. 25. HttpResponseMessage• Represents all the info about the HTTP response Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  26. 26. HttpResponseMessage• Represents all the info about the HTTP response • Status code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  27. 27. HttpResponseMessage• Represents all the info about the HTTP response • Status code • Success flag Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  28. 28. 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
  29. 29. HttpMessageHandler Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  30. 30. HttpMessageHandler• Base class implemented by other objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  31. 31. HttpMessageHandler• Base class implemented by other objects• Most custom processing code goes here Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  32. 32. 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
  33. 33. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  34. 34. Agenda• Pipeline Elements Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  35. 35. Agenda• Pipeline Elements• Client-Side Pipeline Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  36. 36. Agenda• Pipeline Elements• Client-Side Pipeline• Server-Side Pipeline Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  37. 37. Agenda• Pipeline Elements• Client-Side Pipeline• Server-Side Pipeline• Improving CRUD Responses Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  38. 38. Agenda• Pipeline Elements• Client-Side Pipeline• Server-Side Pipeline• Improving CRUD Responses• Exception Handling Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  39. 39. 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
  40. 40. Client-Side Pipeline Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  41. 41. Client-Side Pipeline• HttpClient sends requests Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  42. 42. Client-Side Pipeline• HttpClient sends requests• Request is an HttpRequestMessage Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  43. 43. Client-Side Pipeline• HttpClient sends requests• Request is an HttpRequestMessage• Request is sent to HttpMessageHandler Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  44. 44. Client-Side Pipeline• HttpClient sends requests• Request is an HttpRequestMessage• Request is sent to HttpMessageHandler• HttpMessageHandler returns HttpResponseMessage Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  45. 45. 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
  46. 46. Client-Side Pipeline Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  47. 47. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  48. 48. Agenda• Pipeline Elements Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  49. 49. Agenda• Pipeline Elements• Client-Side Pipeline Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  50. 50. Agenda• Pipeline Elements• Client-Side Pipeline• Server-Side Pipeline Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  51. 51. Agenda• Pipeline Elements• Client-Side Pipeline• Server-Side Pipeline• Improving CRUD Responses Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  52. 52. Agenda• Pipeline Elements• Client-Side Pipeline• Server-Side Pipeline• Improving CRUD Responses• Exception Handling Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  53. 53. 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
  54. 54. Server-Side Pipeline Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  55. 55. Server-Side Pipeline• Web host gives the request to HttpServer Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  56. 56. Server-Side Pipeline• Web host gives the request to HttpServer• Request passed through series of HttpMessageHandlers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  57. 57. Server-Side Pipeline• Web host gives the request to HttpServer• Request passed through series of HttpMessageHandlers• Ends with HttpControllerDispatcher Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  58. 58. 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 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  59. 59. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  60. 60. Agenda• Pipeline Elements Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  61. 61. Agenda• Pipeline Elements• Client-Side Pipeline Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  62. 62. Agenda• Pipeline Elements• Client-Side Pipeline• Server-Side Pipeline Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  63. 63. Agenda• Pipeline Elements• Client-Side Pipeline• Server-Side Pipeline• Improving CRUD Responses Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  64. 64. Agenda• Pipeline Elements• Client-Side Pipeline• Server-Side Pipeline• Improving CRUD Responses• Exception Handling Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  65. 65. 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
  66. 66. Improving CRUD Responses Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  67. 67. Improving CRUD Responses• By default, Web API always sends same HTTP response code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  68. 68. 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
  69. 69. Improving CRUD Responses Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  70. 70. Improving CRUD ResponsesLet’s improve a Web API service’s HTTPresponses! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  71. 71. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  72. 72. Agenda• Pipeline Elements Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  73. 73. Agenda• Pipeline Elements• Client-Side Pipeline Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  74. 74. Agenda• Pipeline Elements• Client-Side Pipeline• Server-Side Pipeline Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  75. 75. Agenda• Pipeline Elements• Client-Side Pipeline• Server-Side Pipeline• Improving CRUD Responses Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  76. 76. Agenda• Pipeline Elements• Client-Side Pipeline• Server-Side Pipeline• Improving CRUD Responses• Exception Handling Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  77. 77. 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
  78. 78. Exception Handling Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  79. 79. Exception Handling• Exceptions tend to be vague on client Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  80. 80. Exception Handling• Exceptions tend to be vague on client• HttpResponseException Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  81. 81. 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
  82. 82. Exception Handling Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  83. 83. Exception HandlingLet’s set up an automated way to sendbetter error messages to the client Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  84. 84. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  85. 85. Agenda• Pipeline Elements Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  86. 86. Agenda• Pipeline Elements• Client-Side Pipeline Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  87. 87. Agenda• Pipeline Elements• Client-Side Pipeline• Server-Side Pipeline Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  88. 88. Agenda• Pipeline Elements• Client-Side Pipeline• Server-Side Pipeline• Improving CRUD Responses Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  89. 89. Agenda• Pipeline Elements• Client-Side Pipeline• Server-Side Pipeline• Improving CRUD Responses• Exception Handling Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  90. 90. 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
  91. 91. Custom Handlers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  92. 92. Custom Handlers• Inherit DelegatingHandler Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  93. 93. Custom Handlers• Inherit DelegatingHandler• Custom code to perform any kind of per request functionality Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  94. 94. Custom Handlers• Inherit DelegatingHandler• Custom code to perform any kind of per request functionality • Logging Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  95. 95. Custom Handlers• Inherit DelegatingHandler• Custom code to perform any kind of per request functionality • Logging • Security Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  96. 96. 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
  97. 97. Custom Handlers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  98. 98. Custom HandlersWe’ll add some security to a Web APIservice Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  99. 99. Learn More! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  100. 100. Learn More!• This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  101. 101. Learn More!• This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  102. 102. 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: Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  103. 103. 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

×