SlideShare une entreprise Scribd logo
1  sur  30
ASP.NET Web API
Contents
• What is an API?
• Why ASP.NET MVC Web API?
• HyperText Transfer Protocol
• REST
• JSON
• Introduction to Web API
Web API
Traditional apps
Browser Request
Index.html
MVC4
Traditional Request / Response for ALL rendered content and assets
Web Application (SPA)
Initial Request
Application.htm
MVC4
RequireJS Loader
Page1 Partial.htm
IndexViewModel.js
Application.js (bootstrap)
ViewModel (#index)
ViewModel (#login)
Model (LoginModel)
JSON Requests
HTML5 localstorage
Handling disconnection
Web API Growth
WCF vs. ASP.NET Web API
POST SimpleService.asmx/EchoString HTTP/1.1
Host: localhost:1489
User-Agent: Mozilla/5.0
Accept: text/html
Content-Type: application/json;
Content-Length: 27
...
XML, JSON, SOAP, AtomPub ...
HTTP Communication
Headers
Data
Verb URL
POST SimpleService.asmx/EchoString HTTP/1.1
Host: localhost:1489
User-Agent: Mozilla/5.0
Accept: text/html,application/xhtml+xml
Content-Type: application/json;
Content-Length: 27
...
JSON vs. SOAP
{
"Age":37,
"FirstName":"Eyal",
"ID":"123",
"LastName":"Vardi“
}
Headers
Data
Verb URL
<Envelope>
<Header>
<!–- Headers -->
<!-- Protocol's & Polices -->
</Header>
<Body>
<!– XML Data -->
</Body>
</Envelope>
Protocols & Formats
SOAP REST OData JSON POX ??
ASP.NET Web API vs. ASP.NET MVC
Dependency Injection
Filters
Content Negotiation
Testing
Embrace HTTP
REST is..
“An architectural style for building
distributed hypermedia systems.”
WSDL vs. REST
WSDL description of a web services
types defined in <xsd:schema>
simple messages
parts of messages
interface specification
operations of an interface
input message
output message
binding of interface to protocols & encoding
description of the binding for each operation
service description
URI and binding to port
<definitions>
<types></types>
<message>
<part></part>
</message>
<portType>
<operation>
<input>
<output>
</operation>
</portType>
<binding>
<operation>
</binding>
<service>
<port>
</service>
</definitions>
From RPC to REST
ASP.NET MVC 4 and the Web API: Building a REST Service from Start to Finish book
URIs and Resources (Routing)
ASP.NET MVC 4 and the Web API: Building a REST Service from Start to Finish book
HTTP Verbs
ASP.NET MVC 4 and the Web API: Building a REST Service from Start to Finish book
“Hypermedia as the engine of
application state” (HATEOAS)
<?xml version="1.0" encoding="utf-8"?>
<Tasks>
<TaskInfo Id="1234" Status="Active" >
<link rel="self" href="/api/tasks/1234" method="GET" />
<link rel="users" href="/api/tasks/1234/users" method="GET" />
<link rel="history" href="/api/tasks/1234/history" method="GET" />
<link rel="complete" href="/api/tasks/1234" method="DELETE" />
<link rel="update" href="/api/tasks/1234" method="PUT" />
</TaskInfo>
<TaskInfo Id="0987" Status="Completed" >
<link rel="self" href="/api/tasks/0987" method="GET" />
<link rel="users" href="/api/tasks/0987/users" method="GET" />
<link rel="history" href="/api/tasks/0987/history" method="GET" />
<link rel="reopen" href="/api/tasks/0987" method="PUT" />
</TaskInfo>
</Tasks>
/api/tasks
“Hypermedia as the engine of
application state” (HATEOAS)
ASP.NET MVC 4 and the Web API: Building a REST Service from Start to Finish book
The Advantages of REST over SOAP
 Simpler API for CRUD
 Standardize Development methodology
 Wide industry adoption, Ease of use
 Smaller payloads than SOAP
 Testability

Contenu connexe

Tendances

Tendances (20)

Rest API
Rest APIRest API
Rest API
 
Understanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsUnderstanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple Steps
 
REST API Design & Development
REST API Design & DevelopmentREST API Design & Development
REST API Design & Development
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
ASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with Overview
 
RESTful API - Best Practices
RESTful API - Best PracticesRESTful API - Best Practices
RESTful API - Best Practices
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developers
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
 
Angular tutorial
Angular tutorialAngular tutorial
Angular tutorial
 
Rest web services
Rest web servicesRest web services
Rest web services
 
Soap vs rest
Soap vs restSoap vs rest
Soap vs rest
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js Express
 
What is an API?
What is an API?What is an API?
What is an API?
 
Introduction to API
Introduction to APIIntroduction to API
Introduction to API
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
Express js
Express jsExpress js
Express js
 
Introduction to APIs (Application Programming Interface)
Introduction to APIs (Application Programming Interface) Introduction to APIs (Application Programming Interface)
Introduction to APIs (Application Programming Interface)
 
Rest api standards and best practices
Rest api standards and best practicesRest api standards and best practices
Rest api standards and best practices
 
Web API Basics
Web API BasicsWeb API Basics
Web API Basics
 
Angularjs PPT
Angularjs PPTAngularjs PPT
Angularjs PPT
 

En vedette

Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
Khaled Musaied
 
Top 9 c#.net interview questions answers
Top 9 c#.net interview questions answersTop 9 c#.net interview questions answers
Top 9 c#.net interview questions answers
Jobinterviews
 
.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework Overview
Doncho Minkov
 

En vedette (20)

MVC - Introduction
MVC - IntroductionMVC - Introduction
MVC - Introduction
 
Dotnet Basics Presentation
Dotnet Basics PresentationDotnet Basics Presentation
Dotnet Basics Presentation
 
MVC 6 Introduction
MVC 6 IntroductionMVC 6 Introduction
MVC 6 Introduction
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
ASP.NET Brief History
ASP.NET Brief HistoryASP.NET Brief History
ASP.NET Brief History
 
ASP.NET WEB API
ASP.NET WEB APIASP.NET WEB API
ASP.NET WEB API
 
C# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENTC# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENT
 
Top 9 c#.net interview questions answers
Top 9 c#.net interview questions answersTop 9 c#.net interview questions answers
Top 9 c#.net interview questions answers
 
Learning ASP.NET 5 and MVC 6
Learning ASP.NET 5 and MVC 6Learning ASP.NET 5 and MVC 6
Learning ASP.NET 5 and MVC 6
 
ASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP FundamentalsASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP Fundamentals
 
.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework Overview
 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
 
Introduction To Dotnet
Introduction To DotnetIntroduction To Dotnet
Introduction To Dotnet
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net framework
 
Architecture of .net framework
Architecture of .net frameworkArchitecture of .net framework
Architecture of .net framework
 
Using Microsoft ASP.NET MVC to Easily Extend a Web Site into the Mobile Space
Using Microsoft ASP.NET MVC to Easily Extend a Web Site into the Mobile SpaceUsing Microsoft ASP.NET MVC to Easily Extend a Web Site into the Mobile Space
Using Microsoft ASP.NET MVC to Easily Extend a Web Site into the Mobile Space
 
Building Next Generation Web Apps and Services using ASP.NET 5
Building Next Generation Web Apps and Services using ASP.NET 5Building Next Generation Web Apps and Services using ASP.NET 5
Building Next Generation Web Apps and Services using ASP.NET 5
 
Intro to asp.net
Intro to asp.netIntro to asp.net
Intro to asp.net
 
Microsoft� .NET and Microsoft� Office 2003
Microsoft� .NET and Microsoft� Office 2003Microsoft� .NET and Microsoft� Office 2003
Microsoft� .NET and Microsoft� Office 2003
 
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for DevelopersMSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
 

Similaire à Web api

Web Tech Java Servlet Update1
Web Tech   Java Servlet Update1Web Tech   Java Servlet Update1
Web Tech Java Servlet Update1
vikram singh
 
An Introduction To Java Web Technology
An Introduction To Java Web TechnologyAn Introduction To Java Web Technology
An Introduction To Java Web Technology
vikram singh
 
Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...
Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...
Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...
Nguyen Duc Phu
 
Anintroductiontojavawebtechnology 090324184240-phpapp01
Anintroductiontojavawebtechnology 090324184240-phpapp01Anintroductiontojavawebtechnology 090324184240-phpapp01
Anintroductiontojavawebtechnology 090324184240-phpapp01
raviIITRoorkee
 

Similaire à Web api (20)

ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
ASP.NET WEB API Training
ASP.NET WEB API TrainingASP.NET WEB API Training
ASP.NET WEB API Training
 
Web api
Web apiWeb api
Web api
 
Enjoying the Move from WCF to the Web API
Enjoying the Move from WCF to the Web APIEnjoying the Move from WCF to the Web API
Enjoying the Move from WCF to the Web API
 
Build Modern Web Apps Using ASP.NET Web API and AngularJS
Build Modern Web Apps Using ASP.NET Web API and AngularJSBuild Modern Web Apps Using ASP.NET Web API and AngularJS
Build Modern Web Apps Using ASP.NET Web API and AngularJS
 
Web Tech Java Servlet Update1
Web Tech   Java Servlet Update1Web Tech   Java Servlet Update1
Web Tech Java Servlet Update1
 
An Introduction To Java Web Technology
An Introduction To Java Web TechnologyAn Introduction To Java Web Technology
An Introduction To Java Web Technology
 
Designing RESTful APIs
Designing RESTful APIsDesigning RESTful APIs
Designing RESTful APIs
 
Rest with Spring
Rest with SpringRest with Spring
Rest with Spring
 
WordPress and Client Side Web Applications WCTO
WordPress and Client Side Web Applications WCTOWordPress and Client Side Web Applications WCTO
WordPress and Client Side Web Applications WCTO
 
Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.
 
Why do you need REST
Why do you need RESTWhy do you need REST
Why do you need REST
 
Wordcamp Toronto Presentation
Wordcamp Toronto PresentationWordcamp Toronto Presentation
Wordcamp Toronto Presentation
 
Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...
Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...
Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...
 
SharePoint 2013 REST APIs
SharePoint 2013 REST APIsSharePoint 2013 REST APIs
SharePoint 2013 REST APIs
 
There is time for rest
There is time for rest There is time for rest
There is time for rest
 
Anintroductiontojavawebtechnology 090324184240-phpapp01
Anintroductiontojavawebtechnology 090324184240-phpapp01Anintroductiontojavawebtechnology 090324184240-phpapp01
Anintroductiontojavawebtechnology 090324184240-phpapp01
 
WebApp #3 : API
WebApp #3 : APIWebApp #3 : API
WebApp #3 : API
 
Servlet by Rj
Servlet by RjServlet by Rj
Servlet by Rj
 
M Ramya
M RamyaM Ramya
M Ramya
 

Dernier

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Dernier (20)

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 

Web api

  • 2. Contents • What is an API? • Why ASP.NET MVC Web API? • HyperText Transfer Protocol • REST • JSON • Introduction to Web API
  • 3.
  • 4.
  • 5.
  • 6.
  • 8.
  • 9.
  • 10.
  • 11. Traditional apps Browser Request Index.html MVC4 Traditional Request / Response for ALL rendered content and assets
  • 12. Web Application (SPA) Initial Request Application.htm MVC4 RequireJS Loader Page1 Partial.htm IndexViewModel.js Application.js (bootstrap) ViewModel (#index) ViewModel (#login) Model (LoginModel) JSON Requests HTML5 localstorage Handling disconnection
  • 14.
  • 15.
  • 16.
  • 17. WCF vs. ASP.NET Web API
  • 18. POST SimpleService.asmx/EchoString HTTP/1.1 Host: localhost:1489 User-Agent: Mozilla/5.0 Accept: text/html Content-Type: application/json; Content-Length: 27 ... XML, JSON, SOAP, AtomPub ... HTTP Communication Headers Data Verb URL
  • 19. POST SimpleService.asmx/EchoString HTTP/1.1 Host: localhost:1489 User-Agent: Mozilla/5.0 Accept: text/html,application/xhtml+xml Content-Type: application/json; Content-Length: 27 ... JSON vs. SOAP { "Age":37, "FirstName":"Eyal", "ID":"123", "LastName":"Vardi“ } Headers Data Verb URL <Envelope> <Header> <!–- Headers --> <!-- Protocol's & Polices --> </Header> <Body> <!– XML Data --> </Body> </Envelope>
  • 20. Protocols & Formats SOAP REST OData JSON POX ??
  • 21. ASP.NET Web API vs. ASP.NET MVC Dependency Injection Filters Content Negotiation Testing
  • 23. REST is.. “An architectural style for building distributed hypermedia systems.”
  • 24. WSDL vs. REST WSDL description of a web services types defined in <xsd:schema> simple messages parts of messages interface specification operations of an interface input message output message binding of interface to protocols & encoding description of the binding for each operation service description URI and binding to port <definitions> <types></types> <message> <part></part> </message> <portType> <operation> <input> <output> </operation> </portType> <binding> <operation> </binding> <service> <port> </service> </definitions>
  • 25. From RPC to REST ASP.NET MVC 4 and the Web API: Building a REST Service from Start to Finish book
  • 26. URIs and Resources (Routing) ASP.NET MVC 4 and the Web API: Building a REST Service from Start to Finish book
  • 27. HTTP Verbs ASP.NET MVC 4 and the Web API: Building a REST Service from Start to Finish book
  • 28. “Hypermedia as the engine of application state” (HATEOAS) <?xml version="1.0" encoding="utf-8"?> <Tasks> <TaskInfo Id="1234" Status="Active" > <link rel="self" href="/api/tasks/1234" method="GET" /> <link rel="users" href="/api/tasks/1234/users" method="GET" /> <link rel="history" href="/api/tasks/1234/history" method="GET" /> <link rel="complete" href="/api/tasks/1234" method="DELETE" /> <link rel="update" href="/api/tasks/1234" method="PUT" /> </TaskInfo> <TaskInfo Id="0987" Status="Completed" > <link rel="self" href="/api/tasks/0987" method="GET" /> <link rel="users" href="/api/tasks/0987/users" method="GET" /> <link rel="history" href="/api/tasks/0987/history" method="GET" /> <link rel="reopen" href="/api/tasks/0987" method="PUT" /> </TaskInfo> </Tasks> /api/tasks
  • 29. “Hypermedia as the engine of application state” (HATEOAS) ASP.NET MVC 4 and the Web API: Building a REST Service from Start to Finish book
  • 30. The Advantages of REST over SOAP  Simpler API for CRUD  Standardize Development methodology  Wide industry adoption, Ease of use  Smaller payloads than SOAP  Testability

Notes de l'éditeur

  1. Use HTTP as an Application Protocol – not a Transport Protocol