SlideShare a Scribd company logo
1 of 38
Christopher Bartling
Nick Spilman
Kevin Hakanson
Basic REST concepts

    Defining your Resource-oriented architecture

    HTTP status codes and error handling

    Content-type negotiation

    Using AJAX with REST

    Versioning REST APIs

    Caching and other performance

    considerations
REpresentational State Transfer

    Architecture style or design criteria

     Not a standard
    Stateless, client-server, cacheable

    communications protocol
    Use HTTP requests to post, read, and delete

    data.
    Lightweight

    Nouns as URI, verbs as HTTP method

Resource

     Anything that important enough to be referenced
      in its singularity
     Can be physical object or an abstract concept
     Every resource has at least one name
    Resources can be a container of other

    resources
     Containers are always resources
     Composite design pattern
Resource representation

     Any useful information about the state of a
      resource
     Specified through distinct URI or content
      negotiation through headers
    Canonical resource URI

     Independent of format or locale language
     Can be specified in Content-Location response
     header of representation response
GET

    http://www.example.com/v1/hr/employees/19328389

    POST

    http://www.example.com/v1/hr/employees

    DELETE

    http://www.example.com/v1/hr/employees/14283949

    PUT

    http://www.example.com/v1/hr/employees/13448784
Addressability

     Resources are identified by URIs
    Statelessness

     No connection state maintained between REST
      invocations
    Connectedness

     Resources should link together in their
      representations
    Uniform interface

     HTTP GET, PUT, POST, DELETE, HEAD, OPTIONS
     HTTP method header
     HTTP status codes
The name and address of a resource

     The scoping information to resources
     Principle of addressability
    Should be descriptive

    Unique URIs are exposed for every resource

    available from a RESTful system
     Every URI designates exactly one resource
    URIs are discoverable by your clients

No state stored on the server

    Every HTTP request executes in complete

    isolation on the server
    Simpler to design and evolve

    Easier to scale

    Avoid using HTTP sessions and cookies

    No side-effects

Standardized

       GET
       POST
       PUT
       DELETE
       HEAD
       OPTIONS
    Represents invocation action

    Resources expose uniform interface

Primary means of reporting the outcome of a

    REST operation
     Use the entity-body to add ancillary qualifiers to
      the outcome
     Do not send back resource representations for
      anything other than GET—negative impact on
      performance optimizations
    See Appendix B of RESTful Web Services

    book for top 42 HTTP status codes
GET and HEAD requests should not cause any

    disastrous changes to the server-side

    No side effects!

     Client should not be making requests just for the
     side effects

    Avoid exposing unsafe operations through

    GET
Multiple invocations of an operation results in

    the same result state as a single invocation

    Idempotent methods: GET, HEAD, PUT,

    DELETE , OPTIONS

    Not idempotent: POST

When creating and updating resources…

     PUT if, and only if, you can fully specify the full
      content of the resource
     POST if you are sending a command to create or
      update one or more subordinates of the specified
      resource
     With POST, the server will determine resource URI
    Use Location header in the POST response to

    specify new resource URI(s) if applicable
HTTPS and SSL certificate validation

    5 main HTTP methods

     GET, HEAD, POST, PUT, DELETE
    Customization of the data sent in the entity-

    body of a PUT or POST request
    Customization of HTTP headers

    Access to the response status code and

    headers
    Communicate through HTTP proxies

Transfer and handle compressed data

     Request: Accept-Encoding header
     Response: Encoding header
    Cache responses to requests

     Conditional GETs
    Common forms of HTTP authentication

     Basic, Digest, and WSSE
    Transparently follow HTTP redirects

Hierarchical

     Encode data into path variables on the URI
     http://maps.example.com/Earth/Europe/France/Paris
    No hierarchy

     Combine into one path variable, separated by
      commas or semicolons
     Use commas when order is important, semicolons
      when it doesn’t
     http://maps.example.com/Earth/24.9195,17.821
Algorithmic resources

     Use query variables
     http://www.google.com/search?q=rest
Version your services!



    Incorporate the version into the URI

     Set version to the first path variable
     GET /v1/users/34923408


    Representations should also be versioned

     Include version information in the representation
Most resources do not change much



    Saves client and server processing time and

    network bandwidth

    Implemented using HTTP headers

     Response headers: Last-Modified and ETag
     Request headers: If-Modified-Since and If-None-
     Match
Initial request for resource representation
Request

    GET /v1/users/10572 HTTP/1.1


    Response

    HTTP/1.1 200 OK
    Last-Modified: Mon, 13 Apr 2009 18:00:00 GMT
    ETag: 1239646841000
    Cache-Control: must-revalidate
    Expires: Thu, 01 Jan 1970 00:00:00 GMT
    Date: Mon, 13 Apr 2009 18:46:00 GMT
Subsequent requests for resource
representation
Request

    GET /v1/users/10572 HTTP/1.1
    If-Modified-Since: Mon, 13 Apr 2009 18:00:00 GMT
    If-None-Match: 1239646841000


    Response

    HTTP/1.1 304 Not Modified
    Date: Mon, 13 Apr 2009 18:47:00 GMT
Microsoft Internet Explorer

     Requires the Expires: -1 header
     Prevents caching in IE
     http://support.microsoft.com/kb/234067
Tools

     .NET
      ▪ Windows Communication Foundation (WCF)
     Java
      ▪ Spring MVC 3.0
      ▪ JAX-RS: CXF, Jersey, RESTEasy, RESTlet
    Design the REST API

     Don’t just let it happen!
     Seek out resources in your domain
Answer the following questions, in order:

    1. What are the URIs? What are the resources of
       your application?
    2. What is the representational format for the
       resources?
    3. What methods are supported at each URI?
    4. What status codes could be returned for each
       method?
Resources can be served in different

    representations
     XML, JSON, HTML, etc.
    Content negotiation methods

     Headers
      ▪ Accept or Content-Type
     Query parameter
      ▪ GET /v1/users/10572?format=json
     URI extension
      ▪ GET /v1/users/10572.xml
Tools

     Curl
     Apache HttpClient and JUnit
     Fiddler (Windows), HTTP Scoop (OS X), WireShark
Using REST as a RPC-like mechanism



    Overusing POST



    Putting actions in the URI



    Disguising a service as a resource



    Maintaining sessions on the server

RESTful Web Services. Leonard Richardson and Sam Ruby.

    http://jcalcote.wordpress.com/2008/10/16/put-or-post-the-rest-of-the-story/

    http://www.elharo.com/blog/software-development/web-development/2005/12/08/post-

    vs-put/
    http://www.xml.com/pub/a/2004/12/01/restful-web.html

    http://www.xml.com/pub/a/2004/03/17/udell.html

    http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm

    http://www.mozilla.org/projects/netlib/http/http-caching-faq.html

    http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html

RESTful Web Services

More Related Content

What's hot

What's hot (20)

REST API
REST APIREST API
REST API
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web API
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
 
REST & RESTful Web Services
REST & RESTful Web ServicesREST & RESTful Web Services
REST & RESTful Web Services
 
Web api
Web apiWeb api
Web api
 
Rest api standards and best practices
Rest api standards and best practicesRest api standards and best practices
Rest api standards and best practices
 
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 overview / concepts
REST-API overview / conceptsREST-API overview / concepts
REST-API overview / concepts
 
Rest & RESTful WebServices
Rest & RESTful WebServicesRest & RESTful WebServices
Rest & RESTful WebServices
 
Rest presentation
Rest  presentationRest  presentation
Rest presentation
 
RESTful API - Best Practices
RESTful API - Best PracticesRESTful API - Best Practices
RESTful API - Best Practices
 
HTTP Request and Response Structure
HTTP Request and Response StructureHTTP Request and Response Structure
HTTP Request and Response Structure
 
API for Beginners
API for BeginnersAPI for Beginners
API for Beginners
 
C# REST API
C# REST APIC# REST API
C# REST API
 
Spring MVC Framework
Spring MVC FrameworkSpring MVC Framework
Spring MVC Framework
 
Learn REST in 18 Slides
Learn REST in 18 SlidesLearn REST in 18 Slides
Learn REST in 18 Slides
 
Soap vs rest
Soap vs restSoap vs rest
Soap vs rest
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web API
 
REST API Design & Development
REST API Design & DevelopmentREST API Design & Development
REST API Design & Development
 
Soap web service
Soap web serviceSoap web service
Soap web service
 

Viewers also liked

Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009
Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009
Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009Cesare Pautasso
 
NEAR FIELD COMMUNICATION
NEAR FIELD COMMUNICATIONNEAR FIELD COMMUNICATION
NEAR FIELD COMMUNICATIONHarisankar U K
 
NFC (Near Field Communication)
NFC (Near Field Communication)NFC (Near Field Communication)
NFC (Near Field Communication)Pushpak Elleedu
 
HyperText Transfer Protocol (HTTP)
HyperText Transfer Protocol (HTTP)HyperText Transfer Protocol (HTTP)
HyperText Transfer Protocol (HTTP)Gurjot Singh
 

Viewers also liked (8)

REST Presentation
REST PresentationREST Presentation
REST Presentation
 
Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009
Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009
Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009
 
Wsdl
WsdlWsdl
Wsdl
 
Nfc ppt
Nfc pptNfc ppt
Nfc ppt
 
NEAR FIELD COMMUNICATION
NEAR FIELD COMMUNICATIONNEAR FIELD COMMUNICATION
NEAR FIELD COMMUNICATION
 
NFC (Near Field Communication)
NFC (Near Field Communication)NFC (Near Field Communication)
NFC (Near Field Communication)
 
HyperText Transfer Protocol (HTTP)
HyperText Transfer Protocol (HTTP)HyperText Transfer Protocol (HTTP)
HyperText Transfer Protocol (HTTP)
 
Verb powerpoint
Verb powerpointVerb powerpoint
Verb powerpoint
 

Similar to RESTful Web Services

01. http basics v27
01. http basics v2701. http basics v27
01. http basics v27Eoin Keary
 
RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座Li Yi
 
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
 
REST & RESTful Web Service
REST & RESTful Web ServiceREST & RESTful Web Service
REST & RESTful Web ServiceHoan Vu Tran
 
RESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSRESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSCarol McDonald
 
Restful webservice
Restful webserviceRestful webservice
Restful webserviceDong Ngoc
 
A RESTful introduction
A RESTful introductionA RESTful introduction
A RESTful introductionDaniel Toader
 
OpenTravel Advisory Forum 2012 REST XML Resources
OpenTravel Advisory Forum 2012 REST XML ResourcesOpenTravel Advisory Forum 2012 REST XML Resources
OpenTravel Advisory Forum 2012 REST XML ResourcesOpenTravel Alliance
 
Resource-Oriented Web Services
Resource-Oriented Web ServicesResource-Oriented Web Services
Resource-Oriented Web ServicesBradley Holt
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API07.pallav
 
KMUTNB - Internet Programming 2/7
KMUTNB - Internet Programming 2/7KMUTNB - Internet Programming 2/7
KMUTNB - Internet Programming 2/7phuphax
 
REST Introduction (PHP London)
REST Introduction (PHP London)REST Introduction (PHP London)
REST Introduction (PHP London)Paul James
 
REST Easy with AngularJS - ng-grid CRUD EXAMPLE
REST Easy with AngularJS - ng-grid CRUD EXAMPLEREST Easy with AngularJS - ng-grid CRUD EXAMPLE
REST Easy with AngularJS - ng-grid CRUD EXAMPLEreneechemel
 
REST Easy with AngularJS - ng-grid CRUD Example
REST Easy with AngularJS - ng-grid CRUD ExampleREST Easy with AngularJS - ng-grid CRUD Example
REST Easy with AngularJS - ng-grid CRUD ExampleBackand Cohen
 

Similar to RESTful Web Services (20)

01. http basics v27
01. http basics v2701. http basics v27
01. http basics v27
 
RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座
 
Doing REST Right
Doing REST RightDoing REST Right
Doing REST Right
 
RESTful services
RESTful servicesRESTful services
RESTful services
 
Web Scraping with PHP
Web Scraping with PHPWeb Scraping with PHP
Web Scraping with PHP
 
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
 
Rest
RestRest
Rest
 
REST & RESTful Web Service
REST & RESTful Web ServiceREST & RESTful Web Service
REST & RESTful Web Service
 
RESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSRESTful Web Services with JAX-RS
RESTful Web Services with JAX-RS
 
Restful webservice
Restful webserviceRestful webservice
Restful webservice
 
A RESTful introduction
A RESTful introductionA RESTful introduction
A RESTful introduction
 
OpenTravel Advisory Forum 2012 REST XML Resources
OpenTravel Advisory Forum 2012 REST XML ResourcesOpenTravel Advisory Forum 2012 REST XML Resources
OpenTravel Advisory Forum 2012 REST XML Resources
 
Resource-Oriented Web Services
Resource-Oriented Web ServicesResource-Oriented Web Services
Resource-Oriented Web Services
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
 
KMUTNB - Internet Programming 2/7
KMUTNB - Internet Programming 2/7KMUTNB - Internet Programming 2/7
KMUTNB - Internet Programming 2/7
 
HTTP Basics Demo
HTTP Basics DemoHTTP Basics Demo
HTTP Basics Demo
 
Woa. Reloaded
Woa. ReloadedWoa. Reloaded
Woa. Reloaded
 
REST Introduction (PHP London)
REST Introduction (PHP London)REST Introduction (PHP London)
REST Introduction (PHP London)
 
REST Easy with AngularJS - ng-grid CRUD EXAMPLE
REST Easy with AngularJS - ng-grid CRUD EXAMPLEREST Easy with AngularJS - ng-grid CRUD EXAMPLE
REST Easy with AngularJS - ng-grid CRUD EXAMPLE
 
REST Easy with AngularJS - ng-grid CRUD Example
REST Easy with AngularJS - ng-grid CRUD ExampleREST Easy with AngularJS - ng-grid CRUD Example
REST Easy with AngularJS - ng-grid CRUD Example
 

More from Christopher Bartling

JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma Christopher Bartling
 
Acceptance Test-driven Development with Cucumber-jvm
Acceptance Test-driven Development with Cucumber-jvmAcceptance Test-driven Development with Cucumber-jvm
Acceptance Test-driven Development with Cucumber-jvmChristopher Bartling
 
JavaScript TDD with Jasmine and Karma
JavaScript TDD with Jasmine and KarmaJavaScript TDD with Jasmine and Karma
JavaScript TDD with Jasmine and KarmaChristopher Bartling
 
Acceptance Test Driven Development With Spec Flow And Friends
Acceptance Test Driven Development With Spec Flow And FriendsAcceptance Test Driven Development With Spec Flow And Friends
Acceptance Test Driven Development With Spec Flow And FriendsChristopher Bartling
 
iPhone OS: The Next Killer Platform
iPhone OS: The Next Killer PlatformiPhone OS: The Next Killer Platform
iPhone OS: The Next Killer PlatformChristopher Bartling
 

More from Christopher Bartling (12)

JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
 
Acceptance Test-driven Development with Cucumber-jvm
Acceptance Test-driven Development with Cucumber-jvmAcceptance Test-driven Development with Cucumber-jvm
Acceptance Test-driven Development with Cucumber-jvm
 
JavaScript TDD with Jasmine and Karma
JavaScript TDD with Jasmine and KarmaJavaScript TDD with Jasmine and Karma
JavaScript TDD with Jasmine and Karma
 
Building Tropo Apps with Grails
Building Tropo Apps with GrailsBuilding Tropo Apps with Grails
Building Tropo Apps with Grails
 
CoffeeScript By Example
CoffeeScript By ExampleCoffeeScript By Example
CoffeeScript By Example
 
Acceptance Test Driven Development With Spec Flow And Friends
Acceptance Test Driven Development With Spec Flow And FriendsAcceptance Test Driven Development With Spec Flow And Friends
Acceptance Test Driven Development With Spec Flow And Friends
 
Introduction To Grails
Introduction To GrailsIntroduction To Grails
Introduction To Grails
 
Cucumber, Cuke4Duke, and Groovy
Cucumber, Cuke4Duke, and GroovyCucumber, Cuke4Duke, and Groovy
Cucumber, Cuke4Duke, and Groovy
 
Test Driven In Groovy
Test Driven In GroovyTest Driven In Groovy
Test Driven In Groovy
 
iPhone OS: The Next Killer Platform
iPhone OS: The Next Killer PlatformiPhone OS: The Next Killer Platform
iPhone OS: The Next Killer Platform
 
Grails Overview
Grails OverviewGrails Overview
Grails Overview
 
Rich Web Clients 20081118
Rich Web Clients 20081118Rich Web Clients 20081118
Rich Web Clients 20081118
 

Recently uploaded

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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
 
[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
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 

Recently uploaded (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
[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
 
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?
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

RESTful Web Services

  • 2. Basic REST concepts  Defining your Resource-oriented architecture  HTTP status codes and error handling  Content-type negotiation  Using AJAX with REST  Versioning REST APIs  Caching and other performance  considerations
  • 3. REpresentational State Transfer  Architecture style or design criteria   Not a standard Stateless, client-server, cacheable  communications protocol Use HTTP requests to post, read, and delete  data. Lightweight  Nouns as URI, verbs as HTTP method 
  • 4. Resource   Anything that important enough to be referenced in its singularity  Can be physical object or an abstract concept  Every resource has at least one name Resources can be a container of other  resources  Containers are always resources  Composite design pattern
  • 5. Resource representation   Any useful information about the state of a resource  Specified through distinct URI or content negotiation through headers Canonical resource URI   Independent of format or locale language  Can be specified in Content-Location response header of representation response
  • 6. GET  http://www.example.com/v1/hr/employees/19328389 POST  http://www.example.com/v1/hr/employees DELETE  http://www.example.com/v1/hr/employees/14283949 PUT  http://www.example.com/v1/hr/employees/13448784
  • 7. Addressability   Resources are identified by URIs Statelessness   No connection state maintained between REST invocations Connectedness   Resources should link together in their representations Uniform interface   HTTP GET, PUT, POST, DELETE, HEAD, OPTIONS  HTTP method header  HTTP status codes
  • 8. The name and address of a resource   The scoping information to resources  Principle of addressability Should be descriptive  Unique URIs are exposed for every resource  available from a RESTful system  Every URI designates exactly one resource URIs are discoverable by your clients 
  • 9. No state stored on the server  Every HTTP request executes in complete  isolation on the server Simpler to design and evolve  Easier to scale  Avoid using HTTP sessions and cookies  No side-effects 
  • 10. Standardized   GET  POST  PUT  DELETE  HEAD  OPTIONS Represents invocation action  Resources expose uniform interface 
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16. Primary means of reporting the outcome of a  REST operation  Use the entity-body to add ancillary qualifiers to the outcome  Do not send back resource representations for anything other than GET—negative impact on performance optimizations See Appendix B of RESTful Web Services  book for top 42 HTTP status codes
  • 17. GET and HEAD requests should not cause any  disastrous changes to the server-side No side effects!   Client should not be making requests just for the side effects Avoid exposing unsafe operations through  GET
  • 18. Multiple invocations of an operation results in  the same result state as a single invocation Idempotent methods: GET, HEAD, PUT,  DELETE , OPTIONS Not idempotent: POST 
  • 19. When creating and updating resources…   PUT if, and only if, you can fully specify the full content of the resource  POST if you are sending a command to create or update one or more subordinates of the specified resource  With POST, the server will determine resource URI Use Location header in the POST response to  specify new resource URI(s) if applicable
  • 20. HTTPS and SSL certificate validation  5 main HTTP methods   GET, HEAD, POST, PUT, DELETE Customization of the data sent in the entity-  body of a PUT or POST request Customization of HTTP headers  Access to the response status code and  headers Communicate through HTTP proxies 
  • 21. Transfer and handle compressed data   Request: Accept-Encoding header  Response: Encoding header Cache responses to requests   Conditional GETs Common forms of HTTP authentication   Basic, Digest, and WSSE Transparently follow HTTP redirects 
  • 22. Hierarchical   Encode data into path variables on the URI  http://maps.example.com/Earth/Europe/France/Paris No hierarchy   Combine into one path variable, separated by commas or semicolons  Use commas when order is important, semicolons when it doesn’t  http://maps.example.com/Earth/24.9195,17.821
  • 23. Algorithmic resources   Use query variables  http://www.google.com/search?q=rest
  • 24. Version your services!  Incorporate the version into the URI   Set version to the first path variable  GET /v1/users/34923408 Representations should also be versioned   Include version information in the representation
  • 25. Most resources do not change much  Saves client and server processing time and  network bandwidth Implemented using HTTP headers   Response headers: Last-Modified and ETag  Request headers: If-Modified-Since and If-None- Match
  • 26. Initial request for resource representation
  • 27. Request  GET /v1/users/10572 HTTP/1.1 Response  HTTP/1.1 200 OK Last-Modified: Mon, 13 Apr 2009 18:00:00 GMT ETag: 1239646841000 Cache-Control: must-revalidate Expires: Thu, 01 Jan 1970 00:00:00 GMT Date: Mon, 13 Apr 2009 18:46:00 GMT
  • 28. Subsequent requests for resource representation
  • 29. Request  GET /v1/users/10572 HTTP/1.1 If-Modified-Since: Mon, 13 Apr 2009 18:00:00 GMT If-None-Match: 1239646841000 Response  HTTP/1.1 304 Not Modified Date: Mon, 13 Apr 2009 18:47:00 GMT
  • 30. Microsoft Internet Explorer   Requires the Expires: -1 header  Prevents caching in IE http://support.microsoft.com/kb/234067
  • 31. Tools   .NET ▪ Windows Communication Foundation (WCF)  Java ▪ Spring MVC 3.0 ▪ JAX-RS: CXF, Jersey, RESTEasy, RESTlet Design the REST API   Don’t just let it happen!  Seek out resources in your domain
  • 32. Answer the following questions, in order:  1. What are the URIs? What are the resources of your application? 2. What is the representational format for the resources? 3. What methods are supported at each URI? 4. What status codes could be returned for each method?
  • 33. Resources can be served in different  representations  XML, JSON, HTML, etc. Content negotiation methods   Headers ▪ Accept or Content-Type  Query parameter ▪ GET /v1/users/10572?format=json  URI extension ▪ GET /v1/users/10572.xml
  • 34. Tools   Curl  Apache HttpClient and JUnit  Fiddler (Windows), HTTP Scoop (OS X), WireShark
  • 35. Using REST as a RPC-like mechanism  Overusing POST  Putting actions in the URI  Disguising a service as a resource  Maintaining sessions on the server 
  • 36.
  • 37. RESTful Web Services. Leonard Richardson and Sam Ruby.  http://jcalcote.wordpress.com/2008/10/16/put-or-post-the-rest-of-the-story/  http://www.elharo.com/blog/software-development/web-development/2005/12/08/post-  vs-put/ http://www.xml.com/pub/a/2004/12/01/restful-web.html  http://www.xml.com/pub/a/2004/03/17/udell.html  http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm  http://www.mozilla.org/projects/netlib/http/http-caching-faq.html  http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html 