
RESTful Web services
The currently more popular Web service model
Following the principles of
Representational State Transfer
(
REST
)
an architecture style for designing networked applications
principles include
client-server, stateless, cacheable, uniform interface,
etc.
As compared to its counterpart,
SOAP web services
,
RESTful
web
services are simplier and easier to implement
there is no official standard for RESTful web services, as
REST
is an
architectural style rather than a protocol
lightweight, highly scalable and maintainable
Client and server typically communicate over HTTP using HTTP
request/response
— same as used between Web browsers and Web
servers

Representations
Messages
Identification of resources (
i.e., URIs
)
Uniform interface
Caching
etc.
Key components of a RESTful Web service

Representations
The purpose of a REST Web service is to provide a window
to its clients so that they can access
resources
Example resources
: image/video files, Web pages, business data,
APIs, or anything that can be represented in a computer system
Resources are identified using
URIs
{
"ID": "1",
"Name": “Steven Lau",
"Email": "[email protected]",
"Country": "Canada"
}
<
Person
>
<
ID
>1</
ID
>
<
Name
>Steven Lau</
Name
>
<
Email
>[email protected]</
Email
>
<
Country
>Canada</
Country
>
</
Person
>
JSON representa8on of a resource
XML representa8on of a resource
Representations
represent the resources and how they are
related to each other
e.g., the server sends data as JSON or XML or HTML, which can be
representations of the same resource

Messages
The client and service communicate with each other via
request/response
messages
HTTP requests and responses are used in HTTP-based RESTful
Web services
POST /services/persons HTTP/1.1
Host:
Content-Type: text/xml; charset=uK-8
Content-Length: xxx
<?
xml
version
=
"1.0"
encoding
=
"uK-8"
?>
<
Person
>
<
ID
>1</
ID
>
<
Name
>Steven Lau</
Name
>
<
Email
>[email protected]</
Email
>
<
Country
>Canada</
Country
>
</
Person
>
HTTP/1.1 200 OK
Date: Fri, 27 Oct 2017 13:31:04 GMT
Server: Apache/2
…
A POST HTTP Request
A HTTP Response

Uniform interfaces to access resources
HTTP interfaces in HTTP-based RESTful Web services
Method
Opera8on performed on server
GET
Request a representa‘on of the specified resource
PUT


You've reached the end of your free preview.
Want to read all 25 pages?
- Fall '13
- Dr. C. Wu
- Computer Science