SlideShare una empresa de 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 !!!

Más contenido relacionado

La actualidad más candente

HTTP Request Header and HTTP Status Code
HTTP Request Header and HTTP Status CodeHTTP Request Header and HTTP Status Code
HTTP Request Header and HTTP Status CodeAbhishek L.R
 
Intro to web services
Intro to web servicesIntro to web services
Intro to web servicesNeil Ghosh
 
Restful Web Services
Restful Web ServicesRestful Web Services
Restful Web ServicesAngelin R
 
REST and RESTful Web Services
REST and RESTful Web ServicesREST and RESTful Web Services
REST and RESTful Web ServicesKasun Madusanke
 
Cookies in servlet
Cookies in servletCookies in servlet
Cookies in servletchauhankapil
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API07.pallav
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate pptAneega
 
Web API testing : A quick glance
Web API testing : A quick glanceWeb API testing : A quick glance
Web API testing : A quick glanceDhanalaxmi K
 
Introduction to APIs (Application Programming Interface)
Introduction to APIs (Application Programming Interface) Introduction to APIs (Application Programming Interface)
Introduction to APIs (Application Programming Interface) Vibhawa Nirmal
 
RESTful API Design Best Practices Using ASP.NET Web API
RESTful API Design Best Practices Using ASP.NET Web APIRESTful API Design Best Practices Using ASP.NET Web API
RESTful API Design Best Practices Using ASP.NET Web API💻 Spencer Schneidenbach
 

La actualidad más candente (20)

HTTP Basics
HTTP BasicsHTTP Basics
HTTP Basics
 
HTTP Request Header and HTTP Status Code
HTTP Request Header and HTTP Status CodeHTTP Request Header and HTTP Status Code
HTTP Request Header and HTTP Status Code
 
Intro to web services
Intro to web servicesIntro to web services
Intro to web services
 
Restful Web Services
Restful Web ServicesRestful Web Services
Restful Web Services
 
Rest API
Rest APIRest API
Rest API
 
REST and RESTful Web Services
REST and RESTful Web ServicesREST and RESTful Web Services
REST and RESTful Web Services
 
Spring Data JPA
Spring Data JPASpring Data JPA
Spring Data JPA
 
Cookies in servlet
Cookies in servletCookies in servlet
Cookies in servlet
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Restful api
Restful apiRestful api
Restful api
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
 
Sessions and cookies
Sessions and cookiesSessions and cookies
Sessions and cookies
 
Web services SOAP
Web services SOAPWeb services SOAP
Web services SOAP
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
 
Web API testing : A quick glance
Web API testing : A quick glanceWeb API testing : A quick glance
Web API testing : A quick glance
 
Introduction to APIs (Application Programming Interface)
Introduction to APIs (Application Programming Interface) Introduction to APIs (Application Programming Interface)
Introduction to APIs (Application Programming Interface)
 
RESTful API Design Best Practices Using ASP.NET Web API
RESTful API Design Best Practices Using ASP.NET Web APIRESTful API Design Best Practices Using ASP.NET Web API
RESTful API Design Best Practices Using ASP.NET Web API
 
Http methods
Http methodsHttp methods
Http methods
 
Spring MVC Framework
Spring MVC FrameworkSpring MVC Framework
Spring MVC Framework
 

Destacado

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
 

Destacado (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
 

Similar a RESTful Web Services Explained

Similar a RESTful Web Services Explained (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

Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 

Último (20)

Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 

RESTful Web Services Explained

  • 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.