rest and asp.net web api (milan)
TRANSCRIPT
![Page 1: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/1.jpg)
REST & ASP.NET Web API@JefClaes
![Page 2: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/2.jpg)
Thanks to the sponsors
![Page 3: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/3.jpg)
about/jefclaes
@jefclaes
http://jefclaes.be
![Page 4: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/4.jpg)
REST
![Page 5: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/5.jpg)
The acronym
REpresentational State Transfer
![Page 6: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/6.jpg)
REST is NOT...
• ‘Webservices using JSON’
• A protocol• A design pattern
![Page 7: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/7.jpg)
REST is..
“An architectural style for building distributed hypermedia systems.”
![Page 8: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/8.jpg)
In theory...
REST isn’t limited to a single message protocol.
![Page 9: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/9.jpg)
But in practice...
It’s all about HTTP.
![Page 10: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/10.jpg)
So now you wonder..
Haven’t we been successfully building web services using SOAP and HTTP
for over 10 years ?
![Page 11: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/11.jpg)
BASIC CONCEPTS
![Page 12: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/12.jpg)
Resources
• An entity, item, or just a thing you want to expose.
• REST is Resource Oriented.
![Page 13: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/13.jpg)
Resources
![Page 14: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/14.jpg)
Resources
![Page 15: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/15.jpg)
Resources
![Page 16: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/16.jpg)
Resources
![Page 17: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/17.jpg)
Identifiers
Something that identifies a resource.
ID: 1URI: http://batman.com/api/batresource/1
![Page 18: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/18.jpg)
Representations
View on a resource’s state at an instant in time.
JSON:
{ "Id":"1", "Description":"Batarang", "Quantity":1}
XML:
<BatResource> <Id>1</Id> <Description> Batarang </Description> <Quantity>1</Quantity></BatResource>
Other:
• Images• CSV• Custom• ...
![Page 19: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/19.jpg)
Verbs
Actions on a resource.
Create Read Update Delete
POST GET PUT DELETE
![Page 20: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/20.jpg)
Hypermedia
HATEOAS: Hypermedia as the engine of application state
Linking your API together
{ "Id":"1", "Description":"Batarang", “Quantity":1, “Links": { "Rel":"Next","Href":"http://localhost:8080/api/batresource/2" }}
![Page 21: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/21.jpg)
HypeRRRRRRRmedia
• Relations• Embedded resources• Reference data• Redistribution of effort• Reduction of payload size• Reflow• Restriction of functionality
![Page 22: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/22.jpg)
ARCHITECTURAL VALUESArchitecture of the WEB
![Page 23: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/23.jpg)
Scalability and performance
Yes, text-based, synchronous, request-response can be performant.• Stateless• Caching
![Page 24: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/24.jpg)
Loose coupling
• No transactions• No state• No guarantees• HATEOAS• No specific technology stack
![Page 25: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/25.jpg)
Consistency and Uniformity
Everybody knows how to use HTTP–Constraints–Well understood semantics
![Page 26: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/26.jpg)
LEFT-OVERS
![Page 27: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/27.jpg)
Richardson’s Maturity Model
Level 0: POX
Level 1: Resources
Level 2: HTTP verbs
Level 3: Hypermedia
![Page 28: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/28.jpg)
ASP.NET WEBAPI
![Page 29: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/29.jpg)
What?
.NET(4.0) HTTP framework for building RESTful services.
![Page 30: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/30.jpg)
When?
• HTTP Services (WCF)
• AJAX back-ends
![Page 31: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/31.jpg)
The server
![Page 32: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/32.jpg)
Options
• WebHost– ASP.NET MVC: Click, click, click
• SelfHost
![Page 33: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/33.jpg)
Starting
![Page 34: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/34.jpg)
Mapping Web API to REST concepts
![Page 35: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/35.jpg)
A resource
![Page 36: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/36.jpg)
A resource
![Page 37: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/37.jpg)
Identifiers
![Page 38: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/38.jpg)
Identifiers
![Page 39: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/39.jpg)
Verbs
![Page 40: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/40.jpg)
Verbs
![Page 41: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/41.jpg)
Representations
![Page 42: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/42.jpg)
Representations
application/jsontext/xml
![Page 43: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/43.jpg)
Representations
![Page 44: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/44.jpg)
Hypermedia
![Page 45: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/45.jpg)
Hypermedia
![Page 46: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/46.jpg)
The Client
![Page 47: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/47.jpg)
Package
Microsoft.AspNet.WebApi.Client
![Page 48: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/48.jpg)
Verbs and asynchrony
![Page 49: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/49.jpg)
Summary
• REST–Concepts–Architectual values– Left overs
• ASP.NET Web API– Server–Client
![Page 50: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/50.jpg)
There is more
Slides and source on http://jefclaes.be
Extensibility?• Next session (Raffaele Rialdi)• http://github.com/JefClaes/aspnet-webapi-samples-tunisia
![Page 51: REST and ASP.NET Web API (Milan)](https://reader033.vdocument.in/reader033/viewer/2022060108/554f9ba2b4c905ad218b483f/html5/thumbnails/51.jpg)
Please rate this sessionScan the code, go online, rate this session