REST &ASP.NET Web API    By @JefClaes
REST
The acronymREpresentational State Transfer
REST is NOT...• „Webservices using JSON‟• A protocol• A design pattern
REST is...“An architectural style for buildingdistributed hypermedia systems.”
In theory...       REST isn‟t limitedto a single message protocol.
But in practice...It‟s all about HTTP.
So now you wonder..Haven‟t we been successfully buildingweb services using SOAP and HTTP         for over 10 years ?
BASIC CONCEPTS
Resources• An entity, item, or just a thing you want to expose.• REST is Resource Oriented.                               ...
IdentifiersSomething that identifies a resource.BIC (= Bank Identifier Code): KREDBEBBURI: http://myapi.com/bank/KREDBEBB
RepresentationsView on a resource‟s state at an instant in time.XML:                    JSON:              Other:<Bank>   ...
VerbsActions on a resource.Read, Update, Delete, AddGET, PUT, DELETE, POST
HypermediaHATEOAS: Hypermedia as the engine of application stateLinking your API together
Architecture of the WEBARCHITECTURAL VALUES
Scalability and performanceYes, text-based, synchronous, request-responsecan be performant.• Stateless• Caching
Loose coupling•   No transactions•   No state•   No guarantees•   HATEOAS•   No specific technology stack
Consistency and UniformityEverybody knows how to use HTTP  – Constraints  – Well understood semantics
LEFT-OVERS
Richardson‟s Maturity Model          Level 0: POX     Level 1: Resources  Level 2: HTTP verbsLevel 3: Hypermedia
Questions?
ASP.NET WEBAPI
What?  .NET (4.0) HTTP frameworkfor building RESTful services.
When?• HTTP Services (WCF)• AJAX back-ends
The server
Options• ASP.NET MVC  – Click, click, click• SelfHost
Selfhost
PackagesMicrosoft.AspNet.WebApi.SelfHost
Starting
Simple CRUD
Creating a controller
Creating a controller
Without conventions• Attributes [HttpGet]• [NonAction]
The Client
PackagesMicrosoft.AspNet.WebApi.Client
POST and GET
Exception handling
Default behaviour &       IncludeErrorDetailPolicy• By default 500 Internal Server Error
HttpResponseException
ErrorFilters
Content negotiation
XML/JSONSupported out of the box:• text/xml• application/json (NewtonSoft)
Custom formatters
Custom formatters
HTTPMessagehandlers
HTTP intermediaries
DelegatingHandler
DelegatingHandler
IoC
IDependencyResolver
IDependencyResolver
Testing
Unit testig
Integration testing in-memory
Summary• REST  – Concepts  – Architectual values  – Left overs• ASP.NET Web API  –   Server/client  –   Exception handling...
Questions
Upcoming SlideShare
Loading in...5
×

REST and ASP.NET Web API (Tunisia)

4,191

Published on

Slides from my session on REST and ASP.NET Web API at the Euricom Tunisia trip.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,191
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
78
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Batbelt?
  • REST and ASP.NET Web API (Tunisia)

    1. 1. REST &ASP.NET Web API By @JefClaes
    2. 2. REST
    3. 3. The acronymREpresentational State Transfer
    4. 4. REST is NOT...• „Webservices using JSON‟• A protocol• A design pattern
    5. 5. REST is...“An architectural style for buildingdistributed hypermedia systems.”
    6. 6. In theory... REST isn‟t limitedto a single message protocol.
    7. 7. But in practice...It‟s all about HTTP.
    8. 8. So now you wonder..Haven‟t we been successfully buildingweb services using SOAP and HTTP for over 10 years ?
    9. 9. BASIC CONCEPTS
    10. 10. Resources• An entity, item, or just a thing you want to expose.• REST is Resource Oriented. A bank
    11. 11. IdentifiersSomething that identifies a resource.BIC (= Bank Identifier Code): KREDBEBBURI: http://myapi.com/bank/KREDBEBB
    12. 12. RepresentationsView on a resource‟s state at an instant in time.XML: JSON: Other:<Bank> { • Images <BIC>KREDBEBB</BIC> "BIC":"123“, • CSV <Name>KBC</Name> “Name”:”KBC” • Custom</Bank> } • ...
    13. 13. VerbsActions on a resource.Read, Update, Delete, AddGET, PUT, DELETE, POST
    14. 14. HypermediaHATEOAS: Hypermedia as the engine of application stateLinking your API together
    15. 15. Architecture of the WEBARCHITECTURAL VALUES
    16. 16. Scalability and performanceYes, text-based, synchronous, request-responsecan be performant.• Stateless• Caching
    17. 17. Loose coupling• No transactions• No state• No guarantees• HATEOAS• No specific technology stack
    18. 18. Consistency and UniformityEverybody knows how to use HTTP – Constraints – Well understood semantics
    19. 19. LEFT-OVERS
    20. 20. Richardson‟s Maturity Model Level 0: POX Level 1: Resources Level 2: HTTP verbsLevel 3: Hypermedia
    21. 21. Questions?
    22. 22. ASP.NET WEBAPI
    23. 23. What? .NET (4.0) HTTP frameworkfor building RESTful services.
    24. 24. When?• HTTP Services (WCF)• AJAX back-ends
    25. 25. The server
    26. 26. Options• ASP.NET MVC – Click, click, click• SelfHost
    27. 27. Selfhost
    28. 28. PackagesMicrosoft.AspNet.WebApi.SelfHost
    29. 29. Starting
    30. 30. Simple CRUD
    31. 31. Creating a controller
    32. 32. Creating a controller
    33. 33. Without conventions• Attributes [HttpGet]• [NonAction]
    34. 34. The Client
    35. 35. PackagesMicrosoft.AspNet.WebApi.Client
    36. 36. POST and GET
    37. 37. Exception handling
    38. 38. Default behaviour & IncludeErrorDetailPolicy• By default 500 Internal Server Error
    39. 39. HttpResponseException
    40. 40. ErrorFilters
    41. 41. Content negotiation
    42. 42. XML/JSONSupported out of the box:• text/xml• application/json (NewtonSoft)
    43. 43. Custom formatters
    44. 44. Custom formatters
    45. 45. HTTPMessagehandlers
    46. 46. HTTP intermediaries
    47. 47. DelegatingHandler
    48. 48. DelegatingHandler
    49. 49. IoC
    50. 50. IDependencyResolver
    51. 51. IDependencyResolver
    52. 52. Testing
    53. 53. Unit testig
    54. 54. Integration testing in-memory
    55. 55. Summary• REST – Concepts – Architectual values – Left overs• ASP.NET Web API – Server/client – Exception handling – Content negotiation – Message handlers – IoC – Testing
    56. 56. Questions
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×