SlideShare uma empresa Scribd logo
1 de 20
REST &
RESTful WEB SERVICE
Power Lunch by Vu Tran
REST & RESTful WEB SERVICE
● REST
● REST Characteristics
● RESTful Web Service
REST
Communication
Server Server
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.)
– HTTP Response codes.
– Media types (xml, json, html, plain text, etc)
HTTP-REST Request Basics
The HTTP request is sent from the client.
– Identifies the location of a resource (URL)
– Specifies the verb, or HTTP method (GET, POST, etc).
– Supplies optional request headers (GET - e.g. name-value
pairs)
– Supplies an optional request body (POST - e.g. form
parameters, attachments, etc.)
HTTP-REST Request Basics
API Server
http://customer.info/customers/12345
Client
● URL : http://customer.info/getCustomersInfo
● Verb or HTTP method : GET
● Request headers : ?id=12345
● Request body : NA
HTTP-REST Response Basics
The HTTP response is sent from the server.
– Gives the status of the processed request. (HTTP code)
– 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.)
HTTP-REST Response Basics
API Server
Client
● HTTP status : 200 OK
● Response headers
Content-Type: text/html
Content-Length: 1024
● Response body
<html>
<!-- some HTML content →
</html>
Response
REST Characteristics
Resources
● URI: Every resource is uniquely addressable using URIs.
Constraints
● Client-Server
● Stateless
● Cacheable
● Layered
● Code on demand (optional)
● Uniform Interface
o Method : Use only HTTP methods (GET, POST, PUT,
DELETE)
o Representation : json, xml, etc
Client-Server
1. Separation of concerns.
2. Client and server are independent from each other.
3. Client doesn’t know anything about the resource which
is kept in the server.
4. Server responds as long as the right requests come in.
➔ Goal: Platform independency and to improve scalability.
Stateless
1. Each request is independent from other requests.
2. No client session data or any context stored on the
server.
3. Every request from client stores the required
information, so that the server can respond.
4. If there are needs for session-specific data, it should be
held and maintained by the client and transferred to the
server with each request as needed.
5. A service layer which doesn’t have to maintain client
sessions is much easier to scale.
Cacheable
1. HTTP responses must be cacheable by the clients.
2. Important for performance.
3. If a new request for the resources comes within a while,
then the cached response will be returned.
Layered System
1. There can be many intermediaries between you and the server you
are connecting to.
2. Actually, a client does not know if it is connected to the last server
or an intermediary server.
3. Intermediaries may improve performance by caching and message
passing.
4. Intermediary servers can increase scalability by load-balancing and
can force clients to form some sort of security policies.
5. This structure can be used when encapsulation is needed.
Code on Demand (optional)
1. Servers can send some kind of executable scripts to the client-
side in order to increase or change the functionality on the client
side.
2. This may cause low visibility, so it is the only optional constraint.
EXAMPLE :
...
<head>
<script src="utility.js" type="text/javascript">
</script>
</head
..
Uniform Interface
1. All resources share a uniform interface for the transfer of state
between client and resource, consisting of
o HTTP Method
o HTTP Status Code
HTTP Methods
OPERATION HTTP METHOD Characteristic
Create POST
Read GET safe, idempotent, cacheable
Update PUT (or POST) idempotent
Delete DELETE idempotent
➔ Idempotent : meaning that the operation will produce the same result no matter how many times
it is repeated
HTTP Status Code
HTTP Status Code Group Comment
1xx Informational (100,101)
2xx Success (200,201)
3xx Redirect (301, 304)
4xx Client error (401, 404, 405)
5xx Server error (500, 503)
RESTful WEB SERVICE
Constraints
● Client-Server
● Stateless
● Cacheable
● Layered
● Code on demand (optional)
● Uniform Interface
➔ If a service does not include all constraints out of «Code on
Demand», it is not a RESTful web service.
RESTful Examplehttp://customer.info/customers/ http://customer.info/customers/12345
GET List the URIs and perhaps other
details of the collection's
customers.
Retrieve a representation of the
addressed customer of the
collection.
PUT Not generally used. Replace the addressed customer of
the collection, or if it does not exist,
create it.
POST Create a new customer’s entry in
the collection.
Not generally used.
DELETE Delete the entire collection. Delete the addressed customer of
the collection.
THANK YOU !!!

Mais conteúdo relacionado

Mais procurados

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 StepsTessa Mero
 
REST and RESTful Web Services
REST and RESTful Web ServicesREST and RESTful Web Services
REST and RESTful Web ServicesKasun Madusanke
 
REST API Design & Development
REST API Design & DevelopmentREST API Design & Development
REST API Design & DevelopmentAshok Pundit
 
Rest presentation
Rest  presentationRest  presentation
Rest presentationsrividhyau
 
Rest api standards and best practices
Rest api standards and best practicesRest api standards and best practices
Rest api standards and best practicesAnkita Mahajan
 
Restful api design
Restful api designRestful api design
Restful api designMizan Riqzia
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developersPatrick Savalle
 
HTTP Request and Response Structure
HTTP Request and Response StructureHTTP Request and Response Structure
HTTP Request and Response StructureBhagyashreeGajera1
 
Soap web service
Soap web serviceSoap web service
Soap web serviceNITT, KAMK
 
Web API 2 Token Based Authentication
Web API 2 Token Based AuthenticationWeb API 2 Token Based Authentication
Web API 2 Token Based Authenticationjeremysbrown
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web APIBrad Genereaux
 
API : l'architecture REST
API : l'architecture RESTAPI : l'architecture REST
API : l'architecture RESTFadel Chafai
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSam Brannen
 

Mais procurados (20)

REST API
REST APIREST API
REST API
 
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 & RESTful Web Services
REST & RESTful Web ServicesREST & RESTful Web Services
REST & RESTful Web Services
 
REST and RESTful Web Services
REST and RESTful Web ServicesREST and RESTful Web Services
REST and RESTful Web Services
 
REST API Design & Development
REST API Design & DevelopmentREST API Design & Development
REST API Design & Development
 
Rest API
Rest APIRest API
Rest API
 
Rest presentation
Rest  presentationRest  presentation
Rest presentation
 
Rest api standards and best practices
Rest api standards and best practicesRest api standards and best practices
Rest api standards and best practices
 
Spring MVC Framework
Spring MVC FrameworkSpring MVC Framework
Spring MVC Framework
 
Restful api design
Restful api designRestful api design
Restful api design
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developers
 
HTTP Request and Response Structure
HTTP Request and Response StructureHTTP Request and Response Structure
HTTP Request and Response Structure
 
Soap web service
Soap web serviceSoap web service
Soap web service
 
Web API 2 Token Based Authentication
Web API 2 Token Based AuthenticationWeb API 2 Token Based Authentication
Web API 2 Token Based Authentication
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web API
 
Soap vs rest
Soap vs restSoap vs rest
Soap vs rest
 
Introduction To REST
Introduction To RESTIntroduction To REST
Introduction To REST
 
C# REST API
C# REST APIC# REST API
C# REST API
 
API : l'architecture REST
API : l'architecture RESTAPI : l'architecture REST
API : l'architecture REST
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 

Destaque

RESTful web
RESTful webRESTful web
RESTful webAlvin Qi
 
Java Script Object Notation (JSON)
Java Script Object Notation (JSON)Java Script Object Notation (JSON)
Java Script Object Notation (JSON)Adnan Sohail
 
Web Services Atomic Transactio
 Web Services Atomic Transactio Web Services Atomic Transactio
Web Services Atomic TransactioRoger Xia
 
Frank Leymann @ BPMN 2010
Frank Leymann @ BPMN 2010Frank Leymann @ BPMN 2010
Frank Leymann @ BPMN 2010bpmn2010
 
Semantic Web Services: A RESTful Approach
Semantic Web Services: A RESTful ApproachSemantic Web Services: A RESTful Approach
Semantic Web Services: A RESTful ApproachOtavio Ferreira
 
Semantic web service
Semantic web serviceSemantic web service
Semantic web servicejean Agnimel
 
Atomic Service Transactions
Atomic Service Transactions Atomic Service Transactions
Atomic Service Transactions WSO2
 
Business Models for Open Source Hardware
Business Models for Open Source HardwareBusiness Models for Open Source Hardware
Business Models for Open Source HardwareBenjamin Tincq
 
Introduction and Advanced Concepts of BPEL
Introduction and Advanced Concepts of BPELIntroduction and Advanced Concepts of BPEL
Introduction and Advanced Concepts of BPELDenis Weerasiri
 
The Semantic Web #9 - Web Ontology Language (OWL)
The Semantic Web #9 - Web Ontology Language (OWL)The Semantic Web #9 - Web Ontology Language (OWL)
The Semantic Web #9 - Web Ontology Language (OWL)Myungjin Lee
 
BPEL, BPEL vs ESB (Integration)
BPEL, BPEL vs ESB (Integration)BPEL, BPEL vs ESB (Integration)
BPEL, BPEL vs ESB (Integration)ejlp12
 
Restful web services by Sreeni Inturi
Restful web services by Sreeni InturiRestful web services by Sreeni Inturi
Restful web services by Sreeni InturiSreeni I
 

Destaque (20)

RESTful web
RESTful webRESTful web
RESTful web
 
Intoduction to php restful web service
Intoduction to php  restful web serviceIntoduction to php  restful web service
Intoduction to php restful web service
 
Java Script Object Notation (JSON)
Java Script Object Notation (JSON)Java Script Object Notation (JSON)
Java Script Object Notation (JSON)
 
Simple service rest
Simple service restSimple service rest
Simple service rest
 
Web Services Atomic Transactio
 Web Services Atomic Transactio Web Services Atomic Transactio
Web Services Atomic Transactio
 
WS-Privacy,
WS-Privacy,WS-Privacy,
WS-Privacy,
 
Frank Leymann @ BPMN 2010
Frank Leymann @ BPMN 2010Frank Leymann @ BPMN 2010
Frank Leymann @ BPMN 2010
 
Soa & Bpel With Web Sphere
Soa & Bpel With Web SphereSoa & Bpel With Web Sphere
Soa & Bpel With Web Sphere
 
Semantic Web Services: A RESTful Approach
Semantic Web Services: A RESTful ApproachSemantic Web Services: A RESTful Approach
Semantic Web Services: A RESTful Approach
 
Semantic web service
Semantic web serviceSemantic web service
Semantic web service
 
Atomic Service Transactions
Atomic Service Transactions Atomic Service Transactions
Atomic Service Transactions
 
Semantic web services
Semantic web servicesSemantic web services
Semantic web services
 
Business Models for Open Source Hardware
Business Models for Open Source HardwareBusiness Models for Open Source Hardware
Business Models for Open Source Hardware
 
Introduction and Advanced Concepts of BPEL
Introduction and Advanced Concepts of BPELIntroduction and Advanced Concepts of BPEL
Introduction and Advanced Concepts of BPEL
 
Soa & Bpel
Soa & BpelSoa & Bpel
Soa & Bpel
 
The Semantic Web #9 - Web Ontology Language (OWL)
The Semantic Web #9 - Web Ontology Language (OWL)The Semantic Web #9 - Web Ontology Language (OWL)
The Semantic Web #9 - Web Ontology Language (OWL)
 
Json tutorial
Json tutorialJson tutorial
Json tutorial
 
BPEL, BPEL vs ESB (Integration)
BPEL, BPEL vs ESB (Integration)BPEL, BPEL vs ESB (Integration)
BPEL, BPEL vs ESB (Integration)
 
Restful web services by Sreeni Inturi
Restful web services by Sreeni InturiRestful web services by Sreeni Inturi
Restful web services by Sreeni Inturi
 
REST Presentation
REST PresentationREST Presentation
REST Presentation
 

Semelhante a REST & RESTful Web Service

Semelhante a REST & RESTful Web Service (20)

Restful web services with java
Restful web services with javaRestful web services with java
Restful web services with java
 
Rest WebAPI with OData
Rest WebAPI with ODataRest WebAPI with OData
Rest WebAPI with OData
 
RESTful web services using java and spring
RESTful web services using java and springRESTful web services using java and spring
RESTful web services using java and spring
 
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
 
SOAP vs REST
SOAP vs RESTSOAP vs REST
SOAP vs REST
 
A Deep Dive into RESTful API Design Part 2
A Deep Dive into RESTful API Design Part 2A Deep Dive into RESTful API Design Part 2
A Deep Dive into RESTful API Design Part 2
 
HTTP
HTTPHTTP
HTTP
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API Recommendations
 
Ch-1_.ppt
Ch-1_.pptCh-1_.ppt
Ch-1_.ppt
 
Restful webservice
Restful webserviceRestful webservice
Restful webservice
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
 
Servlet1.ppt
Servlet1.pptServlet1.ppt
Servlet1.ppt
 
Rest
RestRest
Rest
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
Overview of java web services
Overview of java web servicesOverview of java web services
Overview of java web services
 
Restful webservices
Restful webservicesRestful webservices
Restful webservices
 
Restful webservices
Restful webservicesRestful webservices
Restful webservices
 
RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座
 
RIA and Ajax
RIA and AjaxRIA and Ajax
RIA and Ajax
 

Último

[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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
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
 
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
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
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
 
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
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
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
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 

Último (20)

[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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
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...
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 
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
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

REST & RESTful Web Service

  • 1. REST & RESTful WEB SERVICE Power Lunch by Vu Tran
  • 2. REST & RESTful WEB SERVICE ● REST ● REST Characteristics ● RESTful Web Service
  • 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.) – HTTP Response codes. – Media types (xml, json, html, plain text, etc)
  • 5. HTTP-REST Request Basics The HTTP request is sent from the client. – Identifies the location of a resource (URL) – Specifies the verb, or HTTP method (GET, POST, etc). – Supplies optional request headers (GET - e.g. name-value pairs) – Supplies an optional request body (POST - e.g. form parameters, attachments, etc.)
  • 6. HTTP-REST Request Basics API Server http://customer.info/customers/12345 Client ● URL : http://customer.info/getCustomersInfo ● Verb or HTTP method : GET ● Request headers : ?id=12345 ● Request body : NA
  • 7. HTTP-REST Response Basics The HTTP response is sent from the server. – Gives the status of the processed request. (HTTP code) – 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.)
  • 8. HTTP-REST Response Basics API Server Client ● HTTP status : 200 OK ● Response headers Content-Type: text/html Content-Length: 1024 ● Response body <html> <!-- some HTML content → </html> Response
  • 9. REST Characteristics Resources ● URI: Every resource is uniquely addressable using URIs. Constraints ● Client-Server ● Stateless ● Cacheable ● Layered ● Code on demand (optional) ● Uniform Interface o Method : Use only HTTP methods (GET, POST, PUT, DELETE) o Representation : json, xml, etc
  • 10. Client-Server 1. Separation of concerns. 2. Client and server are independent from each other. 3. Client doesn’t know anything about the resource which is kept in the server. 4. Server responds as long as the right requests come in. ➔ Goal: Platform independency and to improve scalability.
  • 11. Stateless 1. Each request is independent from other requests. 2. No client session data or any context stored on the server. 3. Every request from client stores the required information, so that the server can respond. 4. If there are needs for session-specific data, it should be held and maintained by the client and transferred to the server with each request as needed. 5. A service layer which doesn’t have to maintain client sessions is much easier to scale.
  • 12. Cacheable 1. HTTP responses must be cacheable by the clients. 2. Important for performance. 3. If a new request for the resources comes within a while, then the cached response will be returned.
  • 13. Layered System 1. There can be many intermediaries between you and the server you are connecting to. 2. Actually, a client does not know if it is connected to the last server or an intermediary server. 3. Intermediaries may improve performance by caching and message passing. 4. Intermediary servers can increase scalability by load-balancing and can force clients to form some sort of security policies. 5. This structure can be used when encapsulation is needed.
  • 14. Code on Demand (optional) 1. Servers can send some kind of executable scripts to the client- side in order to increase or change the functionality on the client side. 2. This may cause low visibility, so it is the only optional constraint. EXAMPLE : ... <head> <script src="utility.js" type="text/javascript"> </script> </head ..
  • 15. Uniform Interface 1. All resources share a uniform interface for the transfer of state between client and resource, consisting of o HTTP Method o HTTP Status Code
  • 16. HTTP Methods OPERATION HTTP METHOD Characteristic Create POST Read GET safe, idempotent, cacheable Update PUT (or POST) idempotent Delete DELETE idempotent ➔ Idempotent : meaning that the operation will produce the same result no matter how many times it is repeated
  • 17. HTTP Status Code HTTP Status Code Group Comment 1xx Informational (100,101) 2xx Success (200,201) 3xx Redirect (301, 304) 4xx Client error (401, 404, 405) 5xx Server error (500, 503)
  • 18. RESTful WEB SERVICE Constraints ● Client-Server ● Stateless ● Cacheable ● Layered ● Code on demand (optional) ● Uniform Interface ➔ If a service does not include all constraints out of «Code on Demand», it is not a RESTful web service.
  • 19. RESTful Examplehttp://customer.info/customers/ http://customer.info/customers/12345 GET List the URIs and perhaps other details of the collection's customers. Retrieve a representation of the addressed customer of the collection. PUT Not generally used. Replace the addressed customer of the collection, or if it does not exist, create it. POST Create a new customer’s entry in the collection. Not generally used. DELETE Delete the entire collection. Delete the addressed customer of the collection.