SlideShare una empresa de Scribd logo
1 de 18
I
REST and Web API


Roman Kalita
kalita.roman@gmail.com
@rkregfor
Skype: kalita_roman
I
Why we need REST?
Why speak about it?
From web sites to web Apis
From mobile to data
Representational
State
Transfer
 Architectural style
  based on HTTP protocol usage and
  principles of The Web
 Tightly coupled to HTTP protocol
 Lightweight
 Stateless
 Simple caching “from the box”
 Easy to consume (e.g. mobile devices, JavaScript etc.)
 Goal: scaling, loose coupling and
  compose functionality across service boundaries
Richardson Maturity Model
                            I
 Level3: Hypermedia
 controls

 Level2: HTTP Verbs

 Level1: Resources

 Level0: POX, Single URI
Level0
POX, Single URI, Transport
 The systems focus are service end point URI and
  one HTTP verb (likely POST verb) for communication.


                                AppointmentService
                         GetOpenTimeSlot

                            TimeSlotsList
                                                Servic
Client
                                                  e
                         MakeAppointment

                            ReservationResult
Level1
Resources
 Introduces resources, URIs per resource, but one HTTP ve
 Handling complexity by using divide and conquer,
  breaking a large endpoint down into multiple resources.

                                            http://klinik.com/
         POST            doctors/eberwein       Doctor
                                                  s
                            TimeSlotsList
Client
         POST            slots/15092012
                                                Slots
                            ReservationResult
Level2
 HTTP Verbs

 The system relies on more HTTP verbs and
  HTTP response codes on each resource.


                                            http://klinik.com/
                        doctors/eberwein
         GET            ?date=…&open=1 Doctor
                                         s
                         200 OK TimeSlotsList
Client
         POST            slots/15092012
                                                 Slots
                 204 CREATED ReservationResult
Level3
 Hypermedia

 Introduces discoverability, providing a way of making
  a protocol more self-documenting.
                                                         http://klinik.com/
                            doctors/eberwein
         GET                ?date=…&open=1 Doctor
                           200 OK TimeSlotsList
                                                s
                     <link rel = "/linkrels/slot/book"
Client                      uri = "/slots/5678"/>


         POST                slots/15092012                 Slots

                   204 CREATED ReservationResult
Cooking REST on .NET –
 Web API
 URL Routing to produce clean URLs

 Content Negotiation based on Accept headers
  for request and response serialization

 Support for a host of supported output formats
  including JSON, XML, ATOM

 Extensible (easy to add new formats, custom handlers,
  routing, error handlers)

 Self-hostable in non-Web applications

 Testable using testing concepts similar to MVC
Web API Routing
   Routing “à la” ASP.NET MVC
   Register your routs from Application_Start in Global.asax.cs
RouteTable.Routes.MapHttpRoute(
  name: "UploadDownlaodOnlyTrhougthTransport",
  routeTemplate: "api/transports/{controller}/{id}",
  defaults: new { id = RouteParameter.Optional },
  constraints: new { controller = "uploads|downloads" }
);

RouteTable.Routes.MapHttpRoute(
  name: "AllExceptUploadaDownload",
  routeTemplate: "api/{controller}/{id}",
  defaults: new { id = RouteParameter.Optional },
  constraints:
    new { controller = @"^((?!(downloads|uploads)).)*$" }
);
Web API Controller
     Derived from ApiController
     Actions are mapped to URIs
      via naming convention or attributes
     Deep support for more advanced HTTP features
      via HttpResponseMessage and HttpRequestMessage.
public class ProductsController : ApiController
{
  public IEnumerable<Product> GetAllProducts(){}
  public Product GetProduct(int id) {}
  public HttpResponseMessage PostProduct(Product item) {}
  public void PutProduct(int id, Product contact) {}

    [AcceptVerbs("GET", "HEAD")]
    public Product FindProduct(id) {}
    [HttpGet]
    public Product FindProduct(id) {}
}
OData support
 Support “in the box” for OData $top, $skip, $filter, $orderby,
  advanced support in pre-release
  Install-Package Microsoft.AspNet.WebApi.OData -Pre

  Till release - as alternative use of WCF Data Services
 Queryable attribute to enable OData queries


http://localhost:38856/api/products?$filter=category+eq+'Toys'
[Queryable]
public IQueryable<Product> GetAllProducts()
{
  return repository.GetAll().AsQueryable();
}
Web API extensiblity
 Message handlers
  to handle request and responses

 Action filters
  for custom logic before and after action execution

 Custom formatters
  to add custom media type formats

 Dependency resolver
  to enable dependency injection for controllers
Things that help
HTTP debugging proxies
 Fiddler
  fiddler2.com
 Curl, for cmd-line fans
  curl.haxx.se
 Httpie, for cmd-line fans
  github.com/jkbr/httpie

Debugging
 Wireshark
 Remote debug

Service things
 REST service help page
 Test web client
Read more and references
 RFCs ietf.org/rfc/... URI …/rfc3986.txt,
  URL …/rfc1738.txt HTTP, …/rfc2616.txt

 Web API bloggers
   webapibloggers.com

 ASP.NET Web API
    asp.net/webapi
    aspnetwebstack.codeplex.com

 Alternatives to Web API
    servicestack.net

 Martin Fowler’s article about Richardson Maturity Model
   martinfowler.com/articles/richardsonMaturityModel.ht
    ml
http://www.flickr.com/photos/f-oxymoron/5005673112

Más contenido relacionado

La actualidad más candente

RESTful Web Services with Jersey
RESTful Web Services with JerseyRESTful Web Services with Jersey
RESTful Web Services with JerseyScott Leberknight
 
RESTful Web Services in Drupal7
RESTful Web Services in Drupal7RESTful Web Services in Drupal7
RESTful Web Services in Drupal7bmeme
 
RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座Li Yi
 
The Full Power of ASP.NET Web API
The Full Power of ASP.NET Web APIThe Full Power of ASP.NET Web API
The Full Power of ASP.NET Web APIEyal Vardi
 
Rest and the hypermedia constraint
Rest and the hypermedia constraintRest and the hypermedia constraint
Rest and the hypermedia constraintInviqa
 
UNIT-3 Servlet
UNIT-3 ServletUNIT-3 Servlet
UNIT-3 Servletssbd6985
 
Services in Drupal 8
Services in Drupal 8Services in Drupal 8
Services in Drupal 8Andrei Jechiu
 
Your rest api using laravel
Your rest api using laravelYour rest api using laravel
Your rest api using laravelSulaeman .
 
Securing RESTful Payment APIs Using OAuth 2
Securing RESTful Payment APIs Using OAuth 2Securing RESTful Payment APIs Using OAuth 2
Securing RESTful Payment APIs Using OAuth 2Jonathan LeBlanc
 
5. web api 2 aspdotnet-mvc5-slides
5. web api 2 aspdotnet-mvc5-slides5. web api 2 aspdotnet-mvc5-slides
5. web api 2 aspdotnet-mvc5-slidesMasterCode.vn
 
Restful webservice
Restful webserviceRestful webservice
Restful webserviceDong Ngoc
 

La actualidad más candente (20)

Mule caching strategy with redis cache
Mule caching strategy with redis cacheMule caching strategy with redis cache
Mule caching strategy with redis cache
 
Restful web services ppt
Restful web services pptRestful web services ppt
Restful web services ppt
 
RESTful Web Services with Jersey
RESTful Web Services with JerseyRESTful Web Services with Jersey
RESTful Web Services with Jersey
 
Psr 7 symfony-day
Psr 7 symfony-dayPsr 7 symfony-day
Psr 7 symfony-day
 
SOAP-based Web Services
SOAP-based Web ServicesSOAP-based Web Services
SOAP-based Web Services
 
ASP.NET WEB API
ASP.NET WEB APIASP.NET WEB API
ASP.NET WEB API
 
RESTful Web Services in Drupal7
RESTful Web Services in Drupal7RESTful Web Services in Drupal7
RESTful Web Services in Drupal7
 
Rest web services
Rest web servicesRest web services
Rest web services
 
RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座
 
Soap and Rest
Soap and RestSoap and Rest
Soap and Rest
 
The Full Power of ASP.NET Web API
The Full Power of ASP.NET Web APIThe Full Power of ASP.NET Web API
The Full Power of ASP.NET Web API
 
Rest and the hypermedia constraint
Rest and the hypermedia constraintRest and the hypermedia constraint
Rest and the hypermedia constraint
 
Message enricher in mule
Message enricher in muleMessage enricher in mule
Message enricher in mule
 
UNIT-3 Servlet
UNIT-3 ServletUNIT-3 Servlet
UNIT-3 Servlet
 
Services in Drupal 8
Services in Drupal 8Services in Drupal 8
Services in Drupal 8
 
Your rest api using laravel
Your rest api using laravelYour rest api using laravel
Your rest api using laravel
 
Security in php
Security in phpSecurity in php
Security in php
 
Securing RESTful Payment APIs Using OAuth 2
Securing RESTful Payment APIs Using OAuth 2Securing RESTful Payment APIs Using OAuth 2
Securing RESTful Payment APIs Using OAuth 2
 
5. web api 2 aspdotnet-mvc5-slides
5. web api 2 aspdotnet-mvc5-slides5. web api 2 aspdotnet-mvc5-slides
5. web api 2 aspdotnet-mvc5-slides
 
Restful webservice
Restful webserviceRestful webservice
Restful webservice
 

Destacado

Web development with ASP.NET Web API
Web development with ASP.NET Web APIWeb development with ASP.NET Web API
Web development with ASP.NET Web APIDamir Dobric
 
Windows Azure: Table Store, Service Bus Topics, Push Notifications & Notifica...
Windows Azure: Table Store, Service Bus Topics, Push Notifications & Notifica...Windows Azure: Table Store, Service Bus Topics, Push Notifications & Notifica...
Windows Azure: Table Store, Service Bus Topics, Push Notifications & Notifica...Andrew Badera
 
WCF in .NET 4.0 - TVUG November 2010
WCF in .NET 4.0 - TVUG November 2010WCF in .NET 4.0 - TVUG November 2010
WCF in .NET 4.0 - TVUG November 2010Andrew Badera
 
I've Got SaaSGrid: Now What? (1 of 2)
I've Got SaaSGrid: Now What? (1 of 2)I've Got SaaSGrid: Now What? (1 of 2)
I've Got SaaSGrid: Now What? (1 of 2)Andrew Badera
 
SaaSGrid: What's it good for? (2 of 2)
SaaSGrid: What's it good for? (2 of 2)SaaSGrid: What's it good for? (2 of 2)
SaaSGrid: What's it good for? (2 of 2)Andrew Badera
 

Destacado (6)

Web development with ASP.NET Web API
Web development with ASP.NET Web APIWeb development with ASP.NET Web API
Web development with ASP.NET Web API
 
Windows Azure: Table Store, Service Bus Topics, Push Notifications & Notifica...
Windows Azure: Table Store, Service Bus Topics, Push Notifications & Notifica...Windows Azure: Table Store, Service Bus Topics, Push Notifications & Notifica...
Windows Azure: Table Store, Service Bus Topics, Push Notifications & Notifica...
 
WCF in .NET 4.0 - TVUG November 2010
WCF in .NET 4.0 - TVUG November 2010WCF in .NET 4.0 - TVUG November 2010
WCF in .NET 4.0 - TVUG November 2010
 
I've Got SaaSGrid: Now What? (1 of 2)
I've Got SaaSGrid: Now What? (1 of 2)I've Got SaaSGrid: Now What? (1 of 2)
I've Got SaaSGrid: Now What? (1 of 2)
 
ASP.NET MVC Web API
ASP.NET MVC Web APIASP.NET MVC Web API
ASP.NET MVC Web API
 
SaaSGrid: What's it good for? (2 of 2)
SaaSGrid: What's it good for? (2 of 2)SaaSGrid: What's it good for? (2 of 2)
SaaSGrid: What's it good for? (2 of 2)
 

Similar a REST and Web API

Rest in practice
Rest in practiceRest in practice
Rest in practiceGabor Torok
 
Pentesting web applications
Pentesting web applicationsPentesting web applications
Pentesting web applicationsSatish b
 
Rest presentation
Rest  presentationRest  presentation
Rest presentationsrividhyau
 
Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)Tim Burks
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiTiago Knoch
 
Time to REST: testing web services
Time to REST: testing web servicesTime to REST: testing web services
Time to REST: testing web servicesIurii Kutelmakh
 
Automated testing web services - part 1
Automated testing web services - part 1Automated testing web services - part 1
Automated testing web services - part 1Aleh Struneuski
 
Networked APIs with swift
Networked APIs with swiftNetworked APIs with swift
Networked APIs with swiftTim Burks
 
01. http basics v27
01. http basics v2701. http basics v27
01. http basics v27Eoin Keary
 
Network Device Database Management with REST using Jersey
Network Device Database Management with REST using JerseyNetwork Device Database Management with REST using Jersey
Network Device Database Management with REST using JerseyPayal Jain
 
RESTful services
RESTful servicesRESTful services
RESTful servicesgouthamrv
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsCarol McDonald
 
JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011Shreedhar Ganapathy
 

Similar a REST and Web API (20)

Rest in practice
Rest in practiceRest in practice
Rest in practice
 
RESTful Web Services
RESTful Web ServicesRESTful Web Services
RESTful Web Services
 
Pentesting web applications
Pentesting web applicationsPentesting web applications
Pentesting web applications
 
WebApp #3 : API
WebApp #3 : APIWebApp #3 : API
WebApp #3 : API
 
Rest presentation
Rest  presentationRest  presentation
Rest presentation
 
Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
RESTing with JAX-RS
RESTing with JAX-RSRESTing with JAX-RS
RESTing with JAX-RS
 
Doing REST Right
Doing REST RightDoing REST Right
Doing REST Right
 
Time to REST: testing web services
Time to REST: testing web servicesTime to REST: testing web services
Time to REST: testing web services
 
Automated testing web services - part 1
Automated testing web services - part 1Automated testing web services - part 1
Automated testing web services - part 1
 
Networked APIs with swift
Networked APIs with swiftNetworked APIs with swift
Networked APIs with swift
 
01. http basics v27
01. http basics v2701. http basics v27
01. http basics v27
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
 
Why do you need REST
Why do you need RESTWhy do you need REST
Why do you need REST
 
Network Device Database Management with REST using Jersey
Network Device Database Management with REST using JerseyNetwork Device Database Management with REST using Jersey
Network Device Database Management with REST using Jersey
 
RESTful services
RESTful servicesRESTful services
RESTful services
 
Rest
RestRest
Rest
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.js
 
JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011
 

Más de IT Weekend

Quality attributes testing. From Architecture to test acceptance
Quality attributes testing. From Architecture to test acceptanceQuality attributes testing. From Architecture to test acceptance
Quality attributes testing. From Architecture to test acceptanceIT Weekend
 
Mobile development for JavaScript developer
Mobile development for JavaScript developerMobile development for JavaScript developer
Mobile development for JavaScript developerIT Weekend
 
Building an Innovation & Strategy Process
Building an Innovation & Strategy ProcessBuilding an Innovation & Strategy Process
Building an Innovation & Strategy ProcessIT Weekend
 
IT Professionals – The Right Time/The Right Place
IT Professionals – The Right Time/The Right PlaceIT Professionals – The Right Time/The Right Place
IT Professionals – The Right Time/The Right PlaceIT Weekend
 
Building a Data Driven Organization
Building a Data Driven OrganizationBuilding a Data Driven Organization
Building a Data Driven OrganizationIT Weekend
 
7 Tools for the Product Owner
7 Tools for the Product Owner 7 Tools for the Product Owner
7 Tools for the Product Owner IT Weekend
 
Hacking your Doorbell
Hacking your DoorbellHacking your Doorbell
Hacking your DoorbellIT Weekend
 
An era of possibilities, a window in time
An era of possibilities, a window in timeAn era of possibilities, a window in time
An era of possibilities, a window in timeIT Weekend
 
Web services automation from sketch
Web services automation from sketchWeb services automation from sketch
Web services automation from sketchIT Weekend
 
REST that won't make you cry
REST that won't make you cryREST that won't make you cry
REST that won't make you cryIT Weekend
 
Как договариваться с начальником и заказчиком: выбираем нужный протокол общения
Как договариваться с начальником и заказчиком: выбираем нужный протокол общенияКак договариваться с начальником и заказчиком: выбираем нужный протокол общения
Как договариваться с начальником и заказчиком: выбираем нужный протокол общенияIT Weekend
 
Обзор программы SAP HANA Startup Focus
Обзор программы SAP HANA Startup FocusОбзор программы SAP HANA Startup Focus
Обзор программы SAP HANA Startup FocusIT Weekend
 
World of Agile: Kanban
World of Agile: KanbanWorld of Agile: Kanban
World of Agile: KanbanIT Weekend
 
Risk Management
Risk ManagementRisk Management
Risk ManagementIT Weekend
 
«Spring Integration as Integration Patterns Provider»
«Spring Integration as Integration Patterns Provider»«Spring Integration as Integration Patterns Provider»
«Spring Integration as Integration Patterns Provider»IT Weekend
 
Cutting edge of Machine Learning
Cutting edge of Machine LearningCutting edge of Machine Learning
Cutting edge of Machine LearningIT Weekend
 
Parallel Programming In Modern World .NET Technics
Parallel Programming In Modern World .NET TechnicsParallel Programming In Modern World .NET Technics
Parallel Programming In Modern World .NET TechnicsIT Weekend
 
Parallel programming in modern world .net technics shared
Parallel programming in modern world .net technics   sharedParallel programming in modern world .net technics   shared
Parallel programming in modern world .net technics sharedIT Weekend
 
Maximize Effectiveness of Human Capital
Maximize Effectiveness of Human CapitalMaximize Effectiveness of Human Capital
Maximize Effectiveness of Human CapitalIT Weekend
 

Más de IT Weekend (20)

Quality attributes testing. From Architecture to test acceptance
Quality attributes testing. From Architecture to test acceptanceQuality attributes testing. From Architecture to test acceptance
Quality attributes testing. From Architecture to test acceptance
 
Mobile development for JavaScript developer
Mobile development for JavaScript developerMobile development for JavaScript developer
Mobile development for JavaScript developer
 
Building an Innovation & Strategy Process
Building an Innovation & Strategy ProcessBuilding an Innovation & Strategy Process
Building an Innovation & Strategy Process
 
IT Professionals – The Right Time/The Right Place
IT Professionals – The Right Time/The Right PlaceIT Professionals – The Right Time/The Right Place
IT Professionals – The Right Time/The Right Place
 
Building a Data Driven Organization
Building a Data Driven OrganizationBuilding a Data Driven Organization
Building a Data Driven Organization
 
7 Tools for the Product Owner
7 Tools for the Product Owner 7 Tools for the Product Owner
7 Tools for the Product Owner
 
Hacking your Doorbell
Hacking your DoorbellHacking your Doorbell
Hacking your Doorbell
 
An era of possibilities, a window in time
An era of possibilities, a window in timeAn era of possibilities, a window in time
An era of possibilities, a window in time
 
Web services automation from sketch
Web services automation from sketchWeb services automation from sketch
Web services automation from sketch
 
Why Ruby?
Why Ruby? Why Ruby?
Why Ruby?
 
REST that won't make you cry
REST that won't make you cryREST that won't make you cry
REST that won't make you cry
 
Как договариваться с начальником и заказчиком: выбираем нужный протокол общения
Как договариваться с начальником и заказчиком: выбираем нужный протокол общенияКак договариваться с начальником и заказчиком: выбираем нужный протокол общения
Как договариваться с начальником и заказчиком: выбираем нужный протокол общения
 
Обзор программы SAP HANA Startup Focus
Обзор программы SAP HANA Startup FocusОбзор программы SAP HANA Startup Focus
Обзор программы SAP HANA Startup Focus
 
World of Agile: Kanban
World of Agile: KanbanWorld of Agile: Kanban
World of Agile: Kanban
 
Risk Management
Risk ManagementRisk Management
Risk Management
 
«Spring Integration as Integration Patterns Provider»
«Spring Integration as Integration Patterns Provider»«Spring Integration as Integration Patterns Provider»
«Spring Integration as Integration Patterns Provider»
 
Cutting edge of Machine Learning
Cutting edge of Machine LearningCutting edge of Machine Learning
Cutting edge of Machine Learning
 
Parallel Programming In Modern World .NET Technics
Parallel Programming In Modern World .NET TechnicsParallel Programming In Modern World .NET Technics
Parallel Programming In Modern World .NET Technics
 
Parallel programming in modern world .net technics shared
Parallel programming in modern world .net technics   sharedParallel programming in modern world .net technics   shared
Parallel programming in modern world .net technics shared
 
Maximize Effectiveness of Human Capital
Maximize Effectiveness of Human CapitalMaximize Effectiveness of Human Capital
Maximize Effectiveness of Human Capital
 

Último

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Último (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

REST and Web API

  • 1. I REST and Web API Roman Kalita kalita.roman@gmail.com @rkregfor Skype: kalita_roman
  • 2. I Why we need REST? Why speak about it?
  • 3.
  • 4. From web sites to web Apis From mobile to data
  • 5. Representational State Transfer  Architectural style based on HTTP protocol usage and principles of The Web  Tightly coupled to HTTP protocol  Lightweight  Stateless  Simple caching “from the box”  Easy to consume (e.g. mobile devices, JavaScript etc.)  Goal: scaling, loose coupling and compose functionality across service boundaries
  • 6. Richardson Maturity Model I Level3: Hypermedia controls Level2: HTTP Verbs Level1: Resources Level0: POX, Single URI
  • 7. Level0 POX, Single URI, Transport  The systems focus are service end point URI and one HTTP verb (likely POST verb) for communication. AppointmentService GetOpenTimeSlot TimeSlotsList Servic Client e MakeAppointment ReservationResult
  • 8. Level1 Resources  Introduces resources, URIs per resource, but one HTTP ve  Handling complexity by using divide and conquer, breaking a large endpoint down into multiple resources. http://klinik.com/ POST doctors/eberwein Doctor s TimeSlotsList Client POST slots/15092012 Slots ReservationResult
  • 9. Level2 HTTP Verbs  The system relies on more HTTP verbs and HTTP response codes on each resource. http://klinik.com/ doctors/eberwein GET ?date=…&open=1 Doctor s 200 OK TimeSlotsList Client POST slots/15092012 Slots 204 CREATED ReservationResult
  • 10. Level3 Hypermedia  Introduces discoverability, providing a way of making a protocol more self-documenting. http://klinik.com/ doctors/eberwein GET ?date=…&open=1 Doctor 200 OK TimeSlotsList s <link rel = "/linkrels/slot/book" Client uri = "/slots/5678"/> POST slots/15092012 Slots 204 CREATED ReservationResult
  • 11. Cooking REST on .NET – Web API  URL Routing to produce clean URLs  Content Negotiation based on Accept headers for request and response serialization  Support for a host of supported output formats including JSON, XML, ATOM  Extensible (easy to add new formats, custom handlers, routing, error handlers)  Self-hostable in non-Web applications  Testable using testing concepts similar to MVC
  • 12. Web API Routing  Routing “à la” ASP.NET MVC  Register your routs from Application_Start in Global.asax.cs RouteTable.Routes.MapHttpRoute( name: "UploadDownlaodOnlyTrhougthTransport", routeTemplate: "api/transports/{controller}/{id}", defaults: new { id = RouteParameter.Optional }, constraints: new { controller = "uploads|downloads" } ); RouteTable.Routes.MapHttpRoute( name: "AllExceptUploadaDownload", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional }, constraints: new { controller = @"^((?!(downloads|uploads)).)*$" } );
  • 13. Web API Controller  Derived from ApiController  Actions are mapped to URIs via naming convention or attributes  Deep support for more advanced HTTP features via HttpResponseMessage and HttpRequestMessage. public class ProductsController : ApiController { public IEnumerable<Product> GetAllProducts(){} public Product GetProduct(int id) {} public HttpResponseMessage PostProduct(Product item) {} public void PutProduct(int id, Product contact) {} [AcceptVerbs("GET", "HEAD")] public Product FindProduct(id) {} [HttpGet] public Product FindProduct(id) {} }
  • 14. OData support  Support “in the box” for OData $top, $skip, $filter, $orderby, advanced support in pre-release Install-Package Microsoft.AspNet.WebApi.OData -Pre Till release - as alternative use of WCF Data Services  Queryable attribute to enable OData queries http://localhost:38856/api/products?$filter=category+eq+'Toys' [Queryable] public IQueryable<Product> GetAllProducts() { return repository.GetAll().AsQueryable(); }
  • 15. Web API extensiblity  Message handlers to handle request and responses  Action filters for custom logic before and after action execution  Custom formatters to add custom media type formats  Dependency resolver to enable dependency injection for controllers
  • 16. Things that help HTTP debugging proxies  Fiddler fiddler2.com  Curl, for cmd-line fans curl.haxx.se  Httpie, for cmd-line fans github.com/jkbr/httpie Debugging  Wireshark  Remote debug Service things  REST service help page  Test web client
  • 17. Read more and references  RFCs ietf.org/rfc/... URI …/rfc3986.txt, URL …/rfc1738.txt HTTP, …/rfc2616.txt  Web API bloggers  webapibloggers.com  ASP.NET Web API  asp.net/webapi  aspnetwebstack.codeplex.com  Alternatives to Web API  servicestack.net  Martin Fowler’s article about Richardson Maturity Model  martinfowler.com/articles/richardsonMaturityModel.ht ml