SlideShare a Scribd company logo
1 of 43
REST Webservice
REPRESENTATIONAL STATE TRANSFER
Course Section
 Section 1: REST API Concepts
 Section2: Implementation with Rest Easy
Internal | Department | 11/30/2015 | © Robert Bosch Engineering and Business Solutions Private Limited 2015. All rights reserved, also
regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.
Header of section
Man behind REST
 REST was initially proposed by Roy
Thomas Fielding in his 2000 PhD
dissertation "Architectural Styles
and the Design of Network-based
Software Architectures"
3
REST
REST stands for Representational State Transfer
 It is an architectural pattern for developing web services as opposed to a
specification.
 REST web services communicate over the HTTP specification, using HTTP
vocabulary:
 Methods (GET, POST, etc.)
 HTTP URI syntax (paths, parameters, etc.)
 Media types (xml, json, html, plain text, etc)
 HTTP Response codes.
 Representational
 Clients possess the information necessary to identify, modify, and/or delete a
web resource.
 State
 All resource state information is stored on the client.
 Transfer
 Client state is passed from the client to the service through HTTP.
What is web services?
Web services are services that are exposed to the internet for programmatic
access.
They are online Apis that you can call from your code.
Web Services
https://dev.twitter.com/rest/pu
blic
Real time Scenarios
 http://maps.googleapis.com/maps/api/geocode/json?address=chicago
Web Services Characteristics
 WEB
Protocol
 There is no protocol unlike SOAP.
How the communication happens?
 HTTP Exchange
1. GET
2. POST
3. PUT
4. DELETE
Service Definition
 There is no formal service definition in REST. Unlike SOAP a WSDL is
mandate.
Steps to follow to create REST
 Resource Based URI
 HTTP Methods
 HTTP Status Code
 Message Headers.
Resource Based URI
 Old Web applications URIs look like
Now Get message with id 10. Consumer is not aware of URL.
/getMessages.do?id=10
Rest consumer should be aware of the URL.
Best practice to Name Resources
 Use Nouns not Verbs
 Use /profiles/{profileName}
 /messages/{messageId}
 And most importantly Resourse Based URI are resistant to change.
Naming of resources
Profiles/{profileName}
 The HTTP request is sent from the client.
 Identifies the location of a resource.
 Specifies the verb, or HTTP method to use when accessing the resource.
 Supplies optional request headers (name-value pairs) that provide additional
information the server may need when processing the request.
 Supplies an optional request body that identifies additional data to be
uploaded to the server (e.g. form parameters, attachments, etc.)
Resource – identified by a URL (or uniform resource locator)
Method – the action verb to perform on a resource
e.g. GET, POST, PUT, DELETE, etc.
Request Headers – name-value pairs of meta-information about the request
e.g. Content types expected by the client
Request Body – data to be streamed from the client to the server
e.g. Attachments, form parameters, etc.
 The HTTP response is sent from the server.
 Gives the status of the processed request.
 Supplies response headers (name-value pairs) that provide additional
information about the response.
 Supplies an optional response body that identifies additional data to be
downloaded to the client (html, xml, binary data, etc.)
 Status – An HTTP status code and status message
e.g. 404 Not Found, 200 OK
Response Headers – name-value pairs of meta-information about the
response
e.g. Content-Type
Response Body – Additional data to be streamed from the server to the client
e.g. HTML document, XML document, binary data
HTTP Methods supported by REST:
 GET – Requests a resource at the request URL
 Should not contain a request body, as it will be discarded.
 May be cached locally or on the server.
 May produce a resource, but should not modify on it.
 POST – Submits information to the service for processing
 Should typically return the new or modified resource.
 PUT – Add a new resource at the request URL
 DELETE – Removes the resource at the request URL
 Its safe to make duplicate GET request.
 How about put, post and delete?
 What is difference between Put and Post?
Caching
 Is GET, POST , PUT Cacheable?
 What about browser referesh?
Response
Status codes
 Success Codes
1. 200 – OK
2. 204 – No Content
Client Error Codes
400 – Bad Request
401 – Unauthorized
403 – Forbidden
404 – Not Found
 500 – Internal Server Error
HATEOS
HYPERMEDIA AS THE ENGINE OF APPLICATION STATE
 Avoid hardcoding of URI is client side.
 Helps like documentation of Resourse.
 Provides additional information to consumer for a resource.
 It provides links to resources in API response. URI to next steps are handed
to them in response.
/messages
No HATEOAS
With HATEOAS
Rel Attribute
Richardson Maturity
Model
 Level 0 – Swamp of POX
 One URI. Everything is defined in XML and no HTTP concepts are used.
<create-message>
<message-content>Hello World</message-content>
</create-message>
 Level 1: Resource URI
 Individual URI for each resource. In spite of having “what needs to done” in
message itself.
 Level 2 – HTTP Methods
 Use standard HTTP Methods and error codes.
 Level 3 : Usage of HATEOAS.
 Responses have links that client can use.

More Related Content

What's hot

A Conversation About REST - Extended Version
A Conversation About REST - Extended VersionA Conversation About REST - Extended Version
A Conversation About REST - Extended Version
Jeremy Brown
 
RESTful services
RESTful servicesRESTful services
RESTful services
gouthamrv
 
HTTP Status Codes Cheat Sheet: An Exhaustive List
HTTP Status Codes Cheat Sheet: An Exhaustive ListHTTP Status Codes Cheat Sheet: An Exhaustive List
HTTP Status Codes Cheat Sheet: An Exhaustive List
Mainstreethost
 

What's hot (20)

REST Architecture with use case and example
REST Architecture with use case and exampleREST Architecture with use case and example
REST Architecture with use case and example
 
A Conversation About REST - Extended Version
A Conversation About REST - Extended VersionA Conversation About REST - Extended Version
A Conversation About REST - Extended Version
 
Http Status Code Errors in SEO
Http Status Code Errors in SEOHttp Status Code Errors in SEO
Http Status Code Errors in SEO
 
IRJET- Rest API for E-Commerce Site
IRJET- Rest API for E-Commerce SiteIRJET- Rest API for E-Commerce Site
IRJET- Rest API for E-Commerce Site
 
Web 7 | HTTP Request and Response
Web 7 | HTTP Request and ResponseWeb 7 | HTTP Request and Response
Web 7 | HTTP Request and Response
 
RESTful services
RESTful servicesRESTful services
RESTful services
 
Web Server Technologies I: HTTP & Getting Started
Web Server Technologies I: HTTP & Getting StartedWeb Server Technologies I: HTTP & Getting Started
Web Server Technologies I: HTTP & Getting Started
 
The RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with OracleThe RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with Oracle
 
Rest API Automation with REST Assured
Rest API Automation with REST AssuredRest API Automation with REST Assured
Rest API Automation with REST Assured
 
Introduction To REST
Introduction To RESTIntroduction To REST
Introduction To REST
 
HTTP Status Codes Cheat Sheet: An Exhaustive List
HTTP Status Codes Cheat Sheet: An Exhaustive ListHTTP Status Codes Cheat Sheet: An Exhaustive List
HTTP Status Codes Cheat Sheet: An Exhaustive List
 
Webbasics
WebbasicsWebbasics
Webbasics
 
JSON and REST
JSON and RESTJSON and REST
JSON and REST
 
Learn REST in 18 Slides
Learn REST in 18 SlidesLearn REST in 18 Slides
Learn REST in 18 Slides
 
The Internet as Web Services: introduction to ReST
The Internet as Web Services: introduction to ReSTThe Internet as Web Services: introduction to ReST
The Internet as Web Services: introduction to ReST
 
Rest and the hypermedia constraint
Rest and the hypermedia constraintRest and the hypermedia constraint
Rest and the hypermedia constraint
 
Salesforce Integration
Salesforce IntegrationSalesforce Integration
Salesforce Integration
 
Restful web services
Restful web servicesRestful web services
Restful web services
 
Rest introduction
Rest introductionRest introduction
Rest introduction
 
Richarson maturity model (HATEOAS)
Richarson maturity model (HATEOAS)Richarson maturity model (HATEOAS)
Richarson maturity model (HATEOAS)
 

Similar to Rest Webservice

Similar to Rest Webservice (20)

Best Practices in Api Design
Best Practices in Api DesignBest Practices in Api Design
Best Practices in Api Design
 
WebApp #3 : API
WebApp #3 : APIWebApp #3 : API
WebApp #3 : API
 
Restful Fundamentals
Restful FundamentalsRestful Fundamentals
Restful Fundamentals
 
Restful Fundamentals
Restful FundamentalsRestful Fundamentals
Restful Fundamentals
 
ROA.ppt
ROA.pptROA.ppt
ROA.ppt
 
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
 
Rest
Rest Rest
Rest
 
REST Architecture with use case and example
REST Architecture with use case and exampleREST Architecture with use case and example
REST Architecture with use case and example
 
What are restful web services?
What are restful web services?What are restful web services?
What are restful web services?
 
ReST
ReSTReST
ReST
 
A Look at OData
A Look at ODataA Look at OData
A Look at OData
 
Restful web-services
Restful web-servicesRestful web-services
Restful web-services
 
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
 
6 Months Industrial Training in Spring Framework
6 Months Industrial Training in Spring Framework6 Months Industrial Training in Spring Framework
6 Months Industrial Training in Spring Framework
 
The introduction of RESTful
The introduction of RESTful The introduction of RESTful
The introduction of RESTful
 
REST.ppt
REST.pptREST.ppt
REST.ppt
 
API Basics
API BasicsAPI Basics
API Basics
 
RESTful Web Services
RESTful Web ServicesRESTful Web Services
RESTful Web Services
 
REST - Representational State Transfer
REST - Representational State TransferREST - Representational State Transfer
REST - Representational State Transfer
 
Api design and development
Api design and developmentApi design and development
Api design and development
 

More from Viyaan Jhiingade (7)

Rate limiting
Rate limitingRate limiting
Rate limiting
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
No sql
No sqlNo sql
No sql
 
Storm
StormStorm
Storm
 
Git commands
Git commandsGit commands
Git commands
 
Jenkins CI
Jenkins CIJenkins CI
Jenkins CI
 
Kafka RealTime Streaming
Kafka RealTime StreamingKafka RealTime Streaming
Kafka RealTime Streaming
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Rest Webservice

  • 2. Course Section  Section 1: REST API Concepts  Section2: Implementation with Rest Easy
  • 3. Internal | Department | 11/30/2015 | © Robert Bosch Engineering and Business Solutions Private Limited 2015. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights. Header of section Man behind REST  REST was initially proposed by Roy Thomas Fielding in his 2000 PhD dissertation "Architectural Styles and the Design of Network-based Software Architectures" 3
  • 4. REST REST stands for Representational State Transfer  It is an architectural pattern for developing web services as opposed to a specification.  REST web services communicate over the HTTP specification, using HTTP vocabulary:  Methods (GET, POST, etc.)  HTTP URI syntax (paths, parameters, etc.)  Media types (xml, json, html, plain text, etc)  HTTP Response codes.
  • 5.  Representational  Clients possess the information necessary to identify, modify, and/or delete a web resource.  State  All resource state information is stored on the client.  Transfer  Client state is passed from the client to the service through HTTP.
  • 6. What is web services? Web services are services that are exposed to the internet for programmatic access. They are online Apis that you can call from your code. Web Services
  • 7.
  • 9. Real time Scenarios  http://maps.googleapis.com/maps/api/geocode/json?address=chicago
  • 11. Protocol  There is no protocol unlike SOAP.
  • 12. How the communication happens?  HTTP Exchange 1. GET 2. POST 3. PUT 4. DELETE
  • 13. Service Definition  There is no formal service definition in REST. Unlike SOAP a WSDL is mandate.
  • 14. Steps to follow to create REST  Resource Based URI  HTTP Methods  HTTP Status Code  Message Headers.
  • 15. Resource Based URI  Old Web applications URIs look like Now Get message with id 10. Consumer is not aware of URL. /getMessages.do?id=10 Rest consumer should be aware of the URL.
  • 16. Best practice to Name Resources  Use Nouns not Verbs  Use /profiles/{profileName}  /messages/{messageId}  And most importantly Resourse Based URI are resistant to change.
  • 18.  The HTTP request is sent from the client.  Identifies the location of a resource.  Specifies the verb, or HTTP method to use when accessing the resource.  Supplies optional request headers (name-value pairs) that provide additional information the server may need when processing the request.  Supplies an optional request body that identifies additional data to be uploaded to the server (e.g. form parameters, attachments, etc.)
  • 19. Resource – identified by a URL (or uniform resource locator) Method – the action verb to perform on a resource e.g. GET, POST, PUT, DELETE, etc. Request Headers – name-value pairs of meta-information about the request e.g. Content types expected by the client Request Body – data to be streamed from the client to the server e.g. Attachments, form parameters, etc.
  • 20.  The HTTP response is sent from the server.  Gives the status of the processed request.  Supplies response headers (name-value pairs) that provide additional information about the response.  Supplies an optional response body that identifies additional data to be downloaded to the client (html, xml, binary data, etc.)
  • 21.  Status – An HTTP status code and status message e.g. 404 Not Found, 200 OK Response Headers – name-value pairs of meta-information about the response e.g. Content-Type Response Body – Additional data to be streamed from the server to the client e.g. HTML document, XML document, binary data
  • 22. HTTP Methods supported by REST:  GET – Requests a resource at the request URL  Should not contain a request body, as it will be discarded.  May be cached locally or on the server.  May produce a resource, but should not modify on it.  POST – Submits information to the service for processing  Should typically return the new or modified resource.  PUT – Add a new resource at the request URL  DELETE – Removes the resource at the request URL
  • 23.
  • 24.  Its safe to make duplicate GET request.  How about put, post and delete?  What is difference between Put and Post?
  • 25.
  • 26. Caching  Is GET, POST , PUT Cacheable?  What about browser referesh?
  • 28.
  • 29.
  • 31.  Success Codes 1. 200 – OK 2. 204 – No Content Client Error Codes 400 – Bad Request 401 – Unauthorized 403 – Forbidden 404 – Not Found
  • 32.  500 – Internal Server Error
  • 33. HATEOS HYPERMEDIA AS THE ENGINE OF APPLICATION STATE
  • 34.  Avoid hardcoding of URI is client side.  Helps like documentation of Resourse.  Provides additional information to consumer for a resource.  It provides links to resources in API response. URI to next steps are handed to them in response.
  • 40.  Level 0 – Swamp of POX  One URI. Everything is defined in XML and no HTTP concepts are used. <create-message> <message-content>Hello World</message-content> </create-message>
  • 41.  Level 1: Resource URI  Individual URI for each resource. In spite of having “what needs to done” in message itself.
  • 42.  Level 2 – HTTP Methods  Use standard HTTP Methods and error codes.
  • 43.  Level 3 : Usage of HATEOAS.  Responses have links that client can use.