Presentation is loading. Please wait.

Presentation is loading. Please wait.

06 | HTTP Services with Web API Bruno Terkaly | Technical Evangelist Bret Stateham | Technical Evangelist.

Similar presentations


Presentation on theme: "06 | HTTP Services with Web API Bruno Terkaly | Technical Evangelist Bret Stateham | Technical Evangelist."— Presentation transcript:

1 06 | HTTP Services with Web API Bruno Terkaly | Technical Evangelist Bret Stateham | Technical Evangelist

2 Service Frameworks Review Creating Web API Services Consuming Web API Services Configuring Routes Module Overview

3 Service Frameworks Review

4 WCF “Brand” WCF “Classic” WCF Data Services WCF RIA Services WCF Web HTTP ASP.NET “Brand” ASP.NET Web Services (ASMX) ASP.NET MVC ASP.NET Web API ASP.NET Web API Odata ASP.NET SignalR Web Services “Through the Years” Blatantly stolen from Daniel Roth’s Tech Ed 2013 “Serious Web Services” Session

5 SOAP vs. REST SOAPREST ? XML Based Messaging Contains Envelopes, Headers, Body Can be sent over any transport WS* added Security, Reliability, Transactions… WCF is a full SOAP/WS* Framework REpresenation State Transfer Matches Architecture of the web REST Service = = HTTP Service Leverage HTTP methods (GET,POST,DELETE…) Web API is a way to create an HTTP Service

6 SOAP Client Support Proxy GeneratorNo Simple Proxy Generator

7 REST Client Support HTTP Client

8 Creating Web API Services

9 ASP.NET Web API Open source: aspnetwebstack.codeplex.comaspnetwebstack.codeplex.com –Nightly builds Web API 2 shipped with VS2013 Learn more at asp.net/web-apiasp.net/web-api

10 Creating a Web API Derive from ApiController Implement Actions Actions map to HTTP methods (GET, POST, PUT, DELETE) –Either prefix your action method name with HTTP verb: GetCustomer –Use Attributes if you want to name your action methods differently [HttpGet] [HttpPost] [HttpPut] [HttpDelete]

11 DEMO Creating Web API Services

12 Consuming Web API Services

13 Consuming HTTP Clients Build your client side models (optional) Use the HttpClient to call REST Service URLs –Set headers –Query String –Body (for POST and PUT) Use a JSON Serializer / Deserializer (Like Json.NET) –Map objects to JSON (Serializer) –Map JSON to Objects (Deserializer)

14 DEMO Consuming Web API Services

15 Configuring Web API Services

16 Configuring Routes Routes map URI templates to ApiControllers –Default Route: api/{controller}/id –{controller} + “Controller” = ApiContoller type name –HTTP Verb (Get, Post, Put, Delete) is used to determine action –{id} is passed as an argument to the action method For example: –An HTTP GET to http://mysite.com/api/customer/1http://mysite.com/api/customer/1 –{controller} = “customer” => CustomerController class –HTTP GET implies method that starts with the word “Get” –{id} value looks for a Get(object id) method and passes {id} as arg

17 DEMO Configuring Routes

18 ©2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.


Download ppt "06 | HTTP Services with Web API Bruno Terkaly | Technical Evangelist Bret Stateham | Technical Evangelist."

Similar presentations


Ads by Google