SlideShare a Scribd company logo
06 | HTTP Services with Web API 
Bruno Terkaly | Technical Evangelist 
Bret Stateham | Technical Evangelist
Module Overview 
• Service Frameworks Review 
• Creating Web API Services 
• Consuming Web API Services 
• Configuring Routes
Service Frameworks Review
Web Services “Through the Years” 
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 
Blatantly stolen from Daniel Roth’s Tech Ed 2013 “Serious Web Services” Session
SOAP vs. REST 
? 
SOAP REST 
• 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 =<usually>= HTTP Service 
• Leverage HTTP methods (GET,POST,DELETE…) 
• Web API is a way to create an HTTP Service
SOAP Client Support 
Proxy Generator No Simple Proxy Generator
REST Client Support 
HTTP Client
Creating Web API Services
ASP.NET Web API 
• Open source: aspnetwebstack.codeplex.com 
– Nightly builds 
• Web API 2 shipped with VS2013 
• Learn more at asp.net/web-api
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]
DEMO 
Creating Web API Services
Consuming Web API Services
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)
DEMO 
Consuming Web API Services
Configuring Web API Services
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/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
DEMO 
Configuring Routes
©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.

More Related Content

PPTX
Building solutions with the SharePoint Framework - deep-dive
PDF
Sitecore MVC Forms Localization
PPTX
Deep Dive building solutions on the SharePoint Framework - SPS Brussels 2016
PPTX
Building Modern Websites with ASP.NET by Rachel Appel
PPTX
Building Real Time Applications with ASP.NET SignalR 2.0 by Rachel Appel
PDF
Microservice Websites (microXchg 2017)
PPTX
Introduction to BreezeJs
PPTX
Angular
Building solutions with the SharePoint Framework - deep-dive
Sitecore MVC Forms Localization
Deep Dive building solutions on the SharePoint Framework - SPS Brussels 2016
Building Modern Websites with ASP.NET by Rachel Appel
Building Real Time Applications with ASP.NET SignalR 2.0 by Rachel Appel
Microservice Websites (microXchg 2017)
Introduction to BreezeJs
Angular

What's hot (20)

PPTX
MSDN Sessions 032817 - Azure Functions
PPTX
EXPERTALKS: Feb 2013 - Rise of the Single Page Application
PPTX
SoCal Code Camp 2011 - ASP.NET MVC 4
PPTX
Clean up this mess - API Gateway & Service Discovery in .NET
PPTX
SenchaCon 2016: Enterprise Applications, Role Based Access Controls (RBAC) an...
PDF
AWS Community Day - Piyali Kamra - Conversational AI Ecosystem on AWS
PPTX
GIB2021 - Dan Probert - BizTalk Migrator Deep Dive
PPTX
Angular 2 with typescript
PDF
Tips and Tricks for Building Visual Studio Workflows
PDF
Understanding SharePoint Framework Extensions
PDF
A Simpler Web App Architecture (jDays 2016)
PPTX
Angular js firebase-preso
PPT
Using RESTFUL APIs in ANGULARJS
PPTX
Building Office 365 solutions with React
PPTX
SPSBE18: New era of customizing site provisioning
PPTX
Featfures of asp.net
PPTX
Angular4 kickstart
PPTX
Clean up this mess - API Gateway & Service Discovery in .NET
PDF
Blazor certification training - Dot Net Tricks
PDF
Angularjs & REST
MSDN Sessions 032817 - Azure Functions
EXPERTALKS: Feb 2013 - Rise of the Single Page Application
SoCal Code Camp 2011 - ASP.NET MVC 4
Clean up this mess - API Gateway & Service Discovery in .NET
SenchaCon 2016: Enterprise Applications, Role Based Access Controls (RBAC) an...
AWS Community Day - Piyali Kamra - Conversational AI Ecosystem on AWS
GIB2021 - Dan Probert - BizTalk Migrator Deep Dive
Angular 2 with typescript
Tips and Tricks for Building Visual Studio Workflows
Understanding SharePoint Framework Extensions
A Simpler Web App Architecture (jDays 2016)
Angular js firebase-preso
Using RESTFUL APIs in ANGULARJS
Building Office 365 solutions with React
SPSBE18: New era of customizing site provisioning
Featfures of asp.net
Angular4 kickstart
Clean up this mess - API Gateway & Service Discovery in .NET
Blazor certification training - Dot Net Tricks
Angularjs & REST
Ad

Viewers also liked (6)

PPTX
05 entity framework
PPTX
03 data storage
PPTX
07 advanced topics
PPTX
04 data accesstechnologies
PPTX
02 hosting servicesinwindowsazure
PPTX
1. WCF Services - Exam 70-487
05 entity framework
03 data storage
07 advanced topics
04 data accesstechnologies
02 hosting servicesinwindowsazure
1. WCF Services - Exam 70-487
Ad

Similar to 06 web api (20)

PPTX
Basics Of Introduction to ASP.NET Core.pptx
PPTX
Apps 101 - Moving to the SharePoint 2013 App Model - Presented 7/27/13 at Sha...
PPTX
ASP.NET Mvc 4 web api
PPTX
SFDC Inbound Integrations
PDF
Cert05 70-487 - developing microsoft azure and web services
PPTX
Externalizing Authorization in Micro Services world
PPTX
AWS Summit Barcelona 2015 - Introducing Amazon API Gateway
PDF
Web Development using ASP.NET MVC at HEC
PPTX
SharePoint Client Object Model (CSOM)
PDF
SharePoint Saturday The Conference DC - How the client object model saved the...
PPTX
SharePoint 2013 APIs
PPTX
Web services - A Practical Approach
PPTX
Windows 8 Metro apps and the outside world
PPTX
Developing a provider hosted share point app
PPT
ADO.NET Data Services
PPTX
SharePoint and Office Development Workshop
PPTX
Social Photos - My presentation at Microsoft Tech Day
PPTX
Web API with ASP.NET MVC by Software development company in india
PDF
(ATS6-DEV09) Deep Dive into REST and SOAP Integration for Protocol Authors
PDF
The future of web development write once, run everywhere with angular js an...
Basics Of Introduction to ASP.NET Core.pptx
Apps 101 - Moving to the SharePoint 2013 App Model - Presented 7/27/13 at Sha...
ASP.NET Mvc 4 web api
SFDC Inbound Integrations
Cert05 70-487 - developing microsoft azure and web services
Externalizing Authorization in Micro Services world
AWS Summit Barcelona 2015 - Introducing Amazon API Gateway
Web Development using ASP.NET MVC at HEC
SharePoint Client Object Model (CSOM)
SharePoint Saturday The Conference DC - How the client object model saved the...
SharePoint 2013 APIs
Web services - A Practical Approach
Windows 8 Metro apps and the outside world
Developing a provider hosted share point app
ADO.NET Data Services
SharePoint and Office Development Workshop
Social Photos - My presentation at Microsoft Tech Day
Web API with ASP.NET MVC by Software development company in india
(ATS6-DEV09) Deep Dive into REST and SOAP Integration for Protocol Authors
The future of web development write once, run everywhere with angular js an...

06 web api

  • 1. 06 | HTTP Services with Web API Bruno Terkaly | Technical Evangelist Bret Stateham | Technical Evangelist
  • 2. Module Overview • Service Frameworks Review • Creating Web API Services • Consuming Web API Services • Configuring Routes
  • 4. Web Services “Through the Years” 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 Blatantly stolen from Daniel Roth’s Tech Ed 2013 “Serious Web Services” Session
  • 5. SOAP vs. REST ? SOAP REST • 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 =<usually>= HTTP Service • Leverage HTTP methods (GET,POST,DELETE…) • Web API is a way to create an HTTP Service
  • 6. SOAP Client Support Proxy Generator No Simple Proxy Generator
  • 7. REST Client Support HTTP Client
  • 8. Creating Web API Services
  • 9. ASP.NET Web API • Open source: aspnetwebstack.codeplex.com – Nightly builds • Web API 2 shipped with VS2013 • Learn more at asp.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
  • 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/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
  • 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.

Editor's Notes