SlideShare a Scribd company logo
1 of 61
RESTful Web Services
By Pedram Bashiri
University of North Carolina at Charlotte
Spring 2015
1
Web Server
• Software designed to serve web pages/web sites/web services. Examples
are IIS, Apache, etc.
Web Service
• Application run by a web server, performing tasks and returning structured
data to a calling program, rather than html for a browser.
• Publicly available and standardized for use by all programmers
2
Types of Web Services
3
Service-Oriented Web Services
• Based on “services”
• “Big” Web Services
• JAX-WS = JAVA-API for XML-based Web Services, mainly using WSDL/SOAP
Resource-Oriented Web Services
• Based on “resources”
• RESTfulWeb Services
• JAX-RS = JAVA-API for RESTful Web Services, using only HTTP
4
REST= REpresentational State Transfer
5
What REST is not !
6
REST is not
A framework
7
REST is not
A technology
8
REST is not
A standard specification
9
REST is an architecture style
10
architecture style
An architecture style is a coordinated set of architectural constraints that
restricts the roles and features of architectural elements, and the allowed
relationships between those elements within any architecture that conforms
to that style
● A style can be applied to many architectures
● An architecture can consist of many styles
11
Principles of REST
(ArchitecturalConstraints)
• Statelessness (HTTP)
• Specified Cacheability
• Interface Uniformity (URI)
• Addressability (URI)
• Connectedness (Hypermedia)
12
Statelessness
No Client State
13
Statelessness
Each request from client to server must contain all of the information
necessary to understand the request and cannot take any advantage of any
stored context on the server.
and
Each request contains all of the information necessary for a connector to
understand the request, independent of any requests that may have
preceded it
14
Statelessness
• Improved visibility since a monitoring system does not have to look beyond
a single request
• Improved reliability due to easier recoverability from partial failures
• Improved scalability due to not having to allocate resources for storing
state
• Server does not have to manage resource usage across requests
15
Statelessness
Tradeoff
• Reduced Network Performance
• Reduced server control over application consistency
16
Principles of REST
(ArchitecturalConstraints)
• Statelessness (HTTP)
• Specified Cacheability
• Interface Uniformity (URI)
• Addressability (URI)
• Connectedness (Hypermedia)
17
Specified Cacheability
• Data within a response to a request be implicitly or explicitly labeled as
cacheable or non-cacheable
• If a response is cacheable, then a client cache is given the right to reuse that
response data for later, equivalent requests
18
Specified Cacheability
• Improves efficiency, scalability and user perceived performance
• Tradeoff : Reduced Reliability
19
Principles of REST
(ArchitecturalConstraints)
• Statelessness (HTTP)
• Specified Cacheability
• Interface Uniformity (URI)
• Addressability (URI)
• Connectedness (Hypermedia)
20
Interface Uniformity
• The uniform interface simplifies and decouples the architecture, which
enables each part to evolve independently.
21
Interface Uniformity
Uniform Operations
22
In REST over HTTP these are
• GET= "give me some info" (Retrieve)
• POST= "here's some info to update” (Update)
• PUT= "here's some new info" (Create)
• DELETE= "delete some info" (Delete)
23
Those are the only verbs you need
• Simplifies semantics
• Simplifies client complexity
• Simplifies application model
24
Interface Uniformity
• Tradeoff : Degrades efficiency
• Since Information is transferred in a standard form rather than one which is specific to
application's needs
25
Principles of REST
(ArchitecturalConstraints)
• Statelessness (HTTP)
• Specified Cacheability
• Interface Uniformity (URI)
• Addressability (URI)
• Connectedness (Hypermedia)
26
Addressability through URIs
27
Resources
• Every distinguishable entity is a resource.
• A resource may be aWeb site, an HTML page, an XML document, aWeb
service, an image, a video etc.
28
Addressability
• Every resource is uniquely identified by a URI.
• The URI should generally carry no meaning to the client except as a resource
locator
29
Addressability
• Good, clean, structured URIs are helpful for developers
• If you are naming a specific single resource all the information to locate the
resource should be in the URI itself and not through additional parameters
30
Addressability
eg. Choose
http://informationbase/locationdb/citiestable/pune
not
http://informationbase/locator?type=city&name=pune
31
Principles of REST
(ArchitecturalConstraints)
• Statelessness (HTTP)
• Specified Cacheability
• Interface Uniformity (URI)
• Addressability (URI)
• Connectedness (Hypermedia)
32
Connectedness
• RESTful services representations are hypermedia documents.
• These are documents that contain not just data, but links to other
resources by serving “hypermedia”:
• The quality of having links is called “connectedness”. Resources should link
to each other in their representations.
• Hence, why the human web is easy to use because it is well connected.
33
Representations
• Resources have Representations
• A representation captures the current or intended state of a resource
• Representations are transferred between the client and the server
34
http://www.boeing.com/aircraft/747
<?xml version="1.0"?>
<aircraft>
<model>747</model>
<mfgYr>2000</mfgYr>
</aircraft>
35
http://www.boeing.com/aircraft/747/maintenanceSchedule
<?xml version="1.0"?>
<aircraft>
<model>747</model>
<mfgYr>2000</mfgYr>
<lastMntc>02-02-02<lastMntc>
<nextMntc>12-12-12<nextMntc>
</aircraft>
36
Why is it called "Representational StateTransfer?"
• The Client references aWebresource using a URL.
• A representation of the resource is returned.
• The representation (e.g., Boeing747.html) places the client in a new state.
• When the client selects a hyperlink in Boeing747.html, it accesses another
resource.
• The new representation places the client application into yet another state.
• Thus, the client application transfers state with each resource representation.
37
Representations
• A particular resource may have multiple representations
• Commonly used representation formats are html, xml and json
• however they could also be pdf, png etc.
38
Representations
• When multiple resource formats are supported by the server, the actual
resource format returned is subject to content negotiation between the
client and the server
39
Representations
This should ideally happen through control data i.e. By using HTTP “Accept” headers
and not by appending additional information to the URL.
Prefer
Accept: text/xml;q=0.5, application/json
http://infobase/cities/pune
to
http://infobase/cities/pune.json
40
The Biggest RESTful system?!
ReST extends the very capabilities that made WWW successful into
application design and architecture
What are these characteristics of static WWW and ReST?
41
WWW and ReST
You can connect to any web server if you know the home page URL
You can connect to ReST application if you know the starting URI
42
WWW and ReST
On the home page you can view the content along with the appropriate
hyperlinks which suggest appropriate paths for you to traverse
The response will provide you important initial content along with hyperlinks
which describe their nature to navigate to other resources
43
WWW and ReST
You can save the hyperlink URL, bookmark it or email it to you boss or tweet it
to your friends
A ReST client can store a URI for future use or embed it as a foreign key in
other resources that it maintains
44
WWW and ReST
You can save the contents of any page by saving its HTML representation
You can save the representation of any resource into a XML / Document
database
45
WWW and ReST
You can modify the contents of the web pages by entering data in forms (and
even full page content in blogs,Wikis etc.) and POSTing them.
You can perform PUT, POST and DELETE operations on resources to modify
them
46
WWW and ReST
The server retains no information about the pages you've traversed
The server retains no information about you or the resources you've used
47
WWW and ReST
Did you notice there is no global internet registry for website discovery ?
There is no registry required for ReST applications
48
REST and Security
This is one area where I choose to be non-ReSTful
49
REST and Security
• Sometimes the deliberate requirements of security and transparency of
ReST don't cooperate well
50
REST and Security
• Cookies can help in user identification (other options being Basic HTTP
authentication)
• Basic HTTP Authentication is weak while cookies are strictly used for user
identification only
• But cookies break the statelessness model! 
51
Designing RESTful applications
• Tools
• .NET
• Windows Communication Services (WCF)
• Java
• Spring MVC
• JAX-RS: RESTEasy, RESTLet
52
Designing RESTful applications
• Using a ReST supportive framework does not make your application ReSTful
53
Designing RESTful applications
• You need to model your application interfaces as a set of resources
• And basic CRUD operations on these resources
54
Designing RESTful applications
• Answer these questions in order:
1. What are the resources of your application?What Are the URIs?
2. What is the representational format for the resources?
3. What methods are supported at each URI?
4. What status code could be returned for each method?
55
Designing RESTful applications
56
• As you move from an action oriented design towards resource oriented
design, thinking of everything as nouns is one of the early challenges to
overcome
Transaction.approve becomesTransactionApproval
Account.pay becomes AccountPayment.create
etc.
57
A look forward to increasing ReST popularity
ReST already is starting to dominate the internet space and there's a good
likelihood it could dominate enterprise architectures as well.
58
59
References and Sources
• REST Explained Representational StateTransfer: presentation by Dhananjay Nene
• RESTfulWeb Services: presentation by Imran MYousuf
• Restful web services: presentation by Angelin
• RESTfulWeb Services: presentation by Christopher Bartling, Nick Spilman, Kevin Hakanson
• www.slideshare.com
• www.whatisrest.com
• www.Wikipedia.com
• www.stackoverflow.com
• www.filecatalyst.com/the-connectedness-principle-in-rest/
60
61

More Related Content

What's hot

How the WSO2 ESB outperforms other major open source esb vendors
How the WSO2 ESB outperforms other major open source esb vendorsHow the WSO2 ESB outperforms other major open source esb vendors
How the WSO2 ESB outperforms other major open source esb vendors
WSO2
 

What's hot (20)

Representational state transfer (rest) architectural style1.1
Representational state transfer (rest) architectural style1.1Representational state transfer (rest) architectural style1.1
Representational state transfer (rest) architectural style1.1
 
Introduction to Web Services
Introduction to Web ServicesIntroduction to Web Services
Introduction to Web Services
 
REST API Design
REST API DesignREST API Design
REST API Design
 
gofortution
gofortutiongofortution
gofortution
 
Portal and Intranets
Portal and Intranets Portal and Intranets
Portal and Intranets
 
Best Practice in Web Service Design
Best Practice in Web Service DesignBest Practice in Web Service Design
Best Practice in Web Service Design
 
Design and Implementation of SOA Enhanced Semantic Information Retrieval web ...
Design and Implementation of SOA Enhanced Semantic Information Retrieval web ...Design and Implementation of SOA Enhanced Semantic Information Retrieval web ...
Design and Implementation of SOA Enhanced Semantic Information Retrieval web ...
 
The Rest Architectural Style
The Rest Architectural StyleThe Rest Architectural Style
The Rest Architectural Style
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web services
 
REST and RESTful Web Services
REST and RESTful Web ServicesREST and RESTful Web Services
REST and RESTful Web Services
 
REST and ASP.NET Web API (Tunisia)
REST and ASP.NET Web API (Tunisia)REST and ASP.NET Web API (Tunisia)
REST and ASP.NET Web API (Tunisia)
 
Take a REST!
Take a REST!Take a REST!
Take a REST!
 
How the WSO2 ESB outperforms other major open source esb vendors
How the WSO2 ESB outperforms other major open source esb vendorsHow the WSO2 ESB outperforms other major open source esb vendors
How the WSO2 ESB outperforms other major open source esb vendors
 
Apache Hadoop Security - Ranger
Apache Hadoop Security - RangerApache Hadoop Security - Ranger
Apache Hadoop Security - Ranger
 
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRIS
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRISThe glory of REST in Java: Spring HATEOAS, RAML, Temenos IRIS
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRIS
 
REST Methodologies
REST MethodologiesREST Methodologies
REST Methodologies
 
Hypermedia APIs
Hypermedia APIsHypermedia APIs
Hypermedia APIs
 
What is an API?
What is an API?What is an API?
What is an API?
 
Rest introduction
Rest introductionRest introduction
Rest introduction
 
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
 

Viewers also liked (7)

создание и монтаж
создание и монтажсоздание и монтаж
создание и монтаж
 
реклама
рекламареклама
реклама
 
Стратегии охвата рынка
Стратегии охвата рынкаСтратегии охвата рынка
Стратегии охвата рынка
 
представление числовой информации
представление числовой информациипредставление числовой информации
представление числовой информации
 
задания для системы программирования «кумир»
задания для системы программирования «кумир»задания для системы программирования «кумир»
задания для системы программирования «кумир»
 
Perkembangan penulisan sejarah di indonesia
Perkembangan penulisan sejarah di indonesiaPerkembangan penulisan sejarah di indonesia
Perkembangan penulisan sejarah di indonesia
 
IT-PS Performance Monitoring Solution
IT-PS Performance Monitoring SolutionIT-PS Performance Monitoring Solution
IT-PS Performance Monitoring Solution
 

Similar to RESTful services

Apply API Governance to RESTful Service APIs using WSO2 Governance Registry a...
Apply API Governance to RESTful Service APIs using WSO2 Governance Registry a...Apply API Governance to RESTful Service APIs using WSO2 Governance Registry a...
Apply API Governance to RESTful Service APIs using WSO2 Governance Registry a...
WSO2
 
Understanding REST-Based Services: Simple, Scalable, and Platform Independent
Understanding REST-Based Services: Simple, Scalable, and Platform IndependentUnderstanding REST-Based Services: Simple, Scalable, and Platform Independent
Understanding REST-Based Services: Simple, Scalable, and Platform Independent
Charles Knight
 
Connecting to Data from Windows Phone 8 VSLive! Redmond 2013
Connecting to Data from Windows Phone 8 VSLive! Redmond 2013Connecting to Data from Windows Phone 8 VSLive! Redmond 2013
Connecting to Data from Windows Phone 8 VSLive! Redmond 2013
Woodruff Solutions LLC
 

Similar to RESTful services (20)

REST Introduction.ppt
REST Introduction.pptREST Introduction.ppt
REST Introduction.ppt
 
Overview of REST - Raihan Ullah
Overview of REST - Raihan UllahOverview of REST - Raihan Ullah
Overview of REST - Raihan Ullah
 
Mini-Training: Let's have a rest
Mini-Training: Let's have a restMini-Training: Let's have a rest
Mini-Training: Let's have a rest
 
Rest APIs Training
Rest APIs TrainingRest APIs Training
Rest APIs Training
 
RESTful Services
RESTful ServicesRESTful Services
RESTful Services
 
Rest surekha
Rest surekhaRest surekha
Rest surekha
 
Apply API Governance to RESTful Service APIs using WSO2 Governance Registry a...
Apply API Governance to RESTful Service APIs using WSO2 Governance Registry a...Apply API Governance to RESTful Service APIs using WSO2 Governance Registry a...
Apply API Governance to RESTful Service APIs using WSO2 Governance Registry a...
 
REST != WebAPI
REST != WebAPIREST != WebAPI
REST != WebAPI
 
APIs Design - Creation - Management.pdf
APIs Design - Creation - Management.pdfAPIs Design - Creation - Management.pdf
APIs Design - Creation - Management.pdf
 
REST & RESTful Web Services
REST & RESTful Web ServicesREST & RESTful Web Services
REST & RESTful Web Services
 
Understanding REST-Based Services: Simple, Scalable, and Platform Independent
Understanding REST-Based Services: Simple, Scalable, and Platform IndependentUnderstanding REST-Based Services: Simple, Scalable, and Platform Independent
Understanding REST-Based Services: Simple, Scalable, and Platform Independent
 
Rest introduction
Rest introductionRest introduction
Rest introduction
 
Rest api design
Rest api designRest api design
Rest api design
 
Introduction to REST
Introduction to RESTIntroduction to REST
Introduction to REST
 
Restful风格ž„web服务架构
Restful风格ž„web服务架构Restful风格ž„web服务架构
Restful风格ž„web服务架构
 
Connecting to Data from Windows Phone 8 VSLive! Redmond 2013
Connecting to Data from Windows Phone 8 VSLive! Redmond 2013Connecting to Data from Windows Phone 8 VSLive! Redmond 2013
Connecting to Data from Windows Phone 8 VSLive! Redmond 2013
 
The Characteristics of a RESTful Semantic Web and Why They Are Important
The Characteristics of a RESTful Semantic Web and Why They Are ImportantThe Characteristics of a RESTful Semantic Web and Why They Are Important
The Characteristics of a RESTful Semantic Web and Why They Are Important
 
An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST
 
Connecting to Data from Windows Phone 8
Connecting to Data from Windows Phone 8Connecting to Data from Windows Phone 8
Connecting to Data from Windows Phone 8
 
Rest
RestRest
Rest
 

Recently uploaded

%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 

Recently uploaded (20)

%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 

RESTful services

  • 1. RESTful Web Services By Pedram Bashiri University of North Carolina at Charlotte Spring 2015 1
  • 2. Web Server • Software designed to serve web pages/web sites/web services. Examples are IIS, Apache, etc. Web Service • Application run by a web server, performing tasks and returning structured data to a calling program, rather than html for a browser. • Publicly available and standardized for use by all programmers 2
  • 3. Types of Web Services 3
  • 4. Service-Oriented Web Services • Based on “services” • “Big” Web Services • JAX-WS = JAVA-API for XML-based Web Services, mainly using WSDL/SOAP Resource-Oriented Web Services • Based on “resources” • RESTfulWeb Services • JAX-RS = JAVA-API for RESTful Web Services, using only HTTP 4
  • 6. What REST is not ! 6
  • 7. REST is not A framework 7
  • 8. REST is not A technology 8
  • 9. REST is not A standard specification 9
  • 10. REST is an architecture style 10
  • 11. architecture style An architecture style is a coordinated set of architectural constraints that restricts the roles and features of architectural elements, and the allowed relationships between those elements within any architecture that conforms to that style ● A style can be applied to many architectures ● An architecture can consist of many styles 11
  • 12. Principles of REST (ArchitecturalConstraints) • Statelessness (HTTP) • Specified Cacheability • Interface Uniformity (URI) • Addressability (URI) • Connectedness (Hypermedia) 12
  • 14. Statelessness Each request from client to server must contain all of the information necessary to understand the request and cannot take any advantage of any stored context on the server. and Each request contains all of the information necessary for a connector to understand the request, independent of any requests that may have preceded it 14
  • 15. Statelessness • Improved visibility since a monitoring system does not have to look beyond a single request • Improved reliability due to easier recoverability from partial failures • Improved scalability due to not having to allocate resources for storing state • Server does not have to manage resource usage across requests 15
  • 16. Statelessness Tradeoff • Reduced Network Performance • Reduced server control over application consistency 16
  • 17. Principles of REST (ArchitecturalConstraints) • Statelessness (HTTP) • Specified Cacheability • Interface Uniformity (URI) • Addressability (URI) • Connectedness (Hypermedia) 17
  • 18. Specified Cacheability • Data within a response to a request be implicitly or explicitly labeled as cacheable or non-cacheable • If a response is cacheable, then a client cache is given the right to reuse that response data for later, equivalent requests 18
  • 19. Specified Cacheability • Improves efficiency, scalability and user perceived performance • Tradeoff : Reduced Reliability 19
  • 20. Principles of REST (ArchitecturalConstraints) • Statelessness (HTTP) • Specified Cacheability • Interface Uniformity (URI) • Addressability (URI) • Connectedness (Hypermedia) 20
  • 21. Interface Uniformity • The uniform interface simplifies and decouples the architecture, which enables each part to evolve independently. 21
  • 23. In REST over HTTP these are • GET= "give me some info" (Retrieve) • POST= "here's some info to update” (Update) • PUT= "here's some new info" (Create) • DELETE= "delete some info" (Delete) 23
  • 24. Those are the only verbs you need • Simplifies semantics • Simplifies client complexity • Simplifies application model 24
  • 25. Interface Uniformity • Tradeoff : Degrades efficiency • Since Information is transferred in a standard form rather than one which is specific to application's needs 25
  • 26. Principles of REST (ArchitecturalConstraints) • Statelessness (HTTP) • Specified Cacheability • Interface Uniformity (URI) • Addressability (URI) • Connectedness (Hypermedia) 26
  • 28. Resources • Every distinguishable entity is a resource. • A resource may be aWeb site, an HTML page, an XML document, aWeb service, an image, a video etc. 28
  • 29. Addressability • Every resource is uniquely identified by a URI. • The URI should generally carry no meaning to the client except as a resource locator 29
  • 30. Addressability • Good, clean, structured URIs are helpful for developers • If you are naming a specific single resource all the information to locate the resource should be in the URI itself and not through additional parameters 30
  • 32. Principles of REST (ArchitecturalConstraints) • Statelessness (HTTP) • Specified Cacheability • Interface Uniformity (URI) • Addressability (URI) • Connectedness (Hypermedia) 32
  • 33. Connectedness • RESTful services representations are hypermedia documents. • These are documents that contain not just data, but links to other resources by serving “hypermedia”: • The quality of having links is called “connectedness”. Resources should link to each other in their representations. • Hence, why the human web is easy to use because it is well connected. 33
  • 34. Representations • Resources have Representations • A representation captures the current or intended state of a resource • Representations are transferred between the client and the server 34
  • 37. Why is it called "Representational StateTransfer?" • The Client references aWebresource using a URL. • A representation of the resource is returned. • The representation (e.g., Boeing747.html) places the client in a new state. • When the client selects a hyperlink in Boeing747.html, it accesses another resource. • The new representation places the client application into yet another state. • Thus, the client application transfers state with each resource representation. 37
  • 38. Representations • A particular resource may have multiple representations • Commonly used representation formats are html, xml and json • however they could also be pdf, png etc. 38
  • 39. Representations • When multiple resource formats are supported by the server, the actual resource format returned is subject to content negotiation between the client and the server 39
  • 40. Representations This should ideally happen through control data i.e. By using HTTP “Accept” headers and not by appending additional information to the URL. Prefer Accept: text/xml;q=0.5, application/json http://infobase/cities/pune to http://infobase/cities/pune.json 40
  • 41. The Biggest RESTful system?! ReST extends the very capabilities that made WWW successful into application design and architecture What are these characteristics of static WWW and ReST? 41
  • 42. WWW and ReST You can connect to any web server if you know the home page URL You can connect to ReST application if you know the starting URI 42
  • 43. WWW and ReST On the home page you can view the content along with the appropriate hyperlinks which suggest appropriate paths for you to traverse The response will provide you important initial content along with hyperlinks which describe their nature to navigate to other resources 43
  • 44. WWW and ReST You can save the hyperlink URL, bookmark it or email it to you boss or tweet it to your friends A ReST client can store a URI for future use or embed it as a foreign key in other resources that it maintains 44
  • 45. WWW and ReST You can save the contents of any page by saving its HTML representation You can save the representation of any resource into a XML / Document database 45
  • 46. WWW and ReST You can modify the contents of the web pages by entering data in forms (and even full page content in blogs,Wikis etc.) and POSTing them. You can perform PUT, POST and DELETE operations on resources to modify them 46
  • 47. WWW and ReST The server retains no information about the pages you've traversed The server retains no information about you or the resources you've used 47
  • 48. WWW and ReST Did you notice there is no global internet registry for website discovery ? There is no registry required for ReST applications 48
  • 49. REST and Security This is one area where I choose to be non-ReSTful 49
  • 50. REST and Security • Sometimes the deliberate requirements of security and transparency of ReST don't cooperate well 50
  • 51. REST and Security • Cookies can help in user identification (other options being Basic HTTP authentication) • Basic HTTP Authentication is weak while cookies are strictly used for user identification only • But cookies break the statelessness model!  51
  • 52. Designing RESTful applications • Tools • .NET • Windows Communication Services (WCF) • Java • Spring MVC • JAX-RS: RESTEasy, RESTLet 52
  • 53. Designing RESTful applications • Using a ReST supportive framework does not make your application ReSTful 53
  • 54. Designing RESTful applications • You need to model your application interfaces as a set of resources • And basic CRUD operations on these resources 54
  • 55. Designing RESTful applications • Answer these questions in order: 1. What are the resources of your application?What Are the URIs? 2. What is the representational format for the resources? 3. What methods are supported at each URI? 4. What status code could be returned for each method? 55
  • 57. • As you move from an action oriented design towards resource oriented design, thinking of everything as nouns is one of the early challenges to overcome Transaction.approve becomesTransactionApproval Account.pay becomes AccountPayment.create etc. 57
  • 58. A look forward to increasing ReST popularity ReST already is starting to dominate the internet space and there's a good likelihood it could dominate enterprise architectures as well. 58
  • 59. 59
  • 60. References and Sources • REST Explained Representational StateTransfer: presentation by Dhananjay Nene • RESTfulWeb Services: presentation by Imran MYousuf • Restful web services: presentation by Angelin • RESTfulWeb Services: presentation by Christopher Bartling, Nick Spilman, Kevin Hakanson • www.slideshare.com • www.whatisrest.com • www.Wikipedia.com • www.stackoverflow.com • www.filecatalyst.com/the-connectedness-principle-in-rest/ 60
  • 61. 61

Editor's Notes

  1. Even though it takes away their ability of being called 100% ReSTful