REST and Web Services: in Theory and in Practice: Paul Adamczyk, Patrick H. Smith, Ralph E. Johnson, and Munawar Hafiz
REST and Web Services: in Theory and in Practice: Paul Adamczyk, Patrick H. Smith, Ralph E. Johnson, and Munawar Hafiz
Abstract There are two competing architectural styles employed for building Web
services: RESTful services and services based on the WS– standards (also known
as “SOAP Web services”). These two styles have separate follower bases, but many
differences between them are ideological rather than factual. In order to promote the
healthy growth of Web services research and practice, it is important to distinguish
arguments for implementation practices over abstract concepts represented by these
styles, carefully evaluating the respective advantages of RESTful and WS– Web
services. Understanding these distinctions is especially critical for the development
of enterprise systems, because in this domain, tool vendors have preferred WS–
services to the neglect of RESTful solutions. This chapter evaluates some of the key
questions regarding the real and perceived distinctions between these two styles of
Web services. It analyzes how the current tools for building RESTful Web services
embody the principles of REST. Finally, it presents select open research questions
to further the growth of RESTful Web services.
Introduction
Since its inception, the Web has been an open frontier of exploration in software
and network system design. New ideas were tried and tested first, but organized
and standardized later, once they proved their utility. For example, HTTP, the
transport protocol of the Web, had been in use for more than half a decade before
its state of practice was written down as HTTP/1.0 (Berners-Lee et al. 1996)
in May 1996. But the standardization process continued until 1999, when the
final revision of HTTP/1.1 (Fielding et al. 1999) standard was completed. The
architectural principles behind HTTP and other Web standards were described by
P. Adamczyk ()
Booz Allen Hamilton Inc.
e-mail: [email protected]
Fielding (2000), thus completing the process. HTML has followed a similar path.
It started out with a simple set of tags for structuring text and graphics on Web pages.
As the number of content types [new multimedia formats, more sophisticated ways
of displaying text, interactive Web pages (Garrett 2005)] grew, the HTML tags were
pressed into service of displaying them in various non-standard ways. After nearly
two decades of this growth, new multimedia HTML tags are finally going to be
added and standardized by W3C in HTML5, which is expected to be completed in
2012 (Hickson 2010).
A similar sequence of events – simple beginnings leading to an unruly explosion
followed by some type of organization – can be observed in the realm of Web
services. The first Web services were built for passing remote procedure calls
(RPCs) over the Web. The idea took off quickly and resulted in a large collection
of standards (beginning with SOAP and WSDL). Surprisingly, these standards were
defined with little consideration for the contemporary practice; sometimes before
there were any implementations to standardize. The end result of this premature
standardization was confusion, rather than order that standards usually bring. In
response, an alternative style of Web services, built according to the rules of the
Web, began to appear. These (so-called RESTful) Web services are maturing, or,
more precisely: people are re-learning to use the tried-and-true standards of the Web
and applying them when building Web services. As the two styles of Web services
are used side-by-side, one hopes that they will begin to have positive effects on one
another. Currently, the interactions and comparisons begin to reach a constructive
stage, so this is a good time to stop and reflect on the current state of affairs.
In particular, this chapter focuses on the interpretation of the widely used term,
REST. Roy Fielding coined the term and codified it under four principles. In
practice, people are implementing it in many ways, each harboring certain implicit
conventions of the developers. Following the path of practice dictating the standards,
we raise questions about the previously accepted views about REST and Web
services, and identify the challenges raised by the current state of practice.
Having a standard meaning of RESTfulness would engage the enterprise commu-
nity. REST has been an important part of “renegade” Web services, appealing more
to independent, small-scale and “hip” developers. With concerted research effort,
it would fulfill the stricter requirements of enterprise Web services; conversely, the
enterprise services would benefit from its simplicity.
We begin by summarizing the theory behind RESTful Web services, and draw
a comparison with WS– services. Next, we look into the usage patterns of Web
services in practice: both RESTful services and WS– services. Then, we discuss
some of the problems facing the existing RESTful services, how these problems
make it harder to apply RESTful services to large enterprise systems, and how tools
for implementing them help to alleviate these problems. We conclude by surveying
some of the outstanding research problems of RESTful Web services.
Conventions used in this chapter. We consider two dominant styles of Web ser-
vices: RESTful and WS–. The term Representational State Transfer (REST) was
coined by Roy Fielding to identify an architectural style based on a set of principles
2 REST and Web Services: In Theory and in Practice 37
Although this task was undertaken many times before, presenting a fair comparison
of WS– and RESTful Web services remains a daunting task. In this section, we
will describe their guiding principles and summarize two studies that compare these
architectural styles.
Principles
Roy Fielding documented REST based on the principles that emerged as the Web
evolved (Fielding 2000). He noticed that Web servers, clients, and intermediaries
shared some principles that gave them extensibility to work on the large-scale
of the Internet. He identified four principles of REST (which he called con-
straints) (Fielding 2000):
1. Identification of resources.
2. Manipulation of resources through representations.
3. Self-descriptive messages.
4. Hypermedia as the engine of application state (abbreviated HATEOAS).
These principles describe the architecture of systems and interactions that make
up the Web. The building blocks of the Web are called resources. A resource
is anything that can be named as a target of hypertext (e.g., a file, a script, a
collection of resources). In response to a request for a resource, the client receives a
representation of that resource, which may have a different format than the resource
owned by the server. Resources are manipulated via messages that have standard
meanings; on the Web, these messages are the HTTP methods. The fourth principle
means that the state of any client–server interaction is kept in the hypermedia they
exchange, i.e., links, or URIs. Any state information is passed between the client and
the server in each message, thus keeping them both stateless. It’s easy to check any
design against such a simple description. Any discrepancies will be easy to identify.
However, this simplicity is deceptive – if one tries to simplify it even more, the
entire design suffers. We will discuss concrete examples of oversimplifying REST
in some Web services in “REST Concepts in Practice”.
38 P. Adamczyk et al.
The actual comparison has two problems. First, they use the numbers of
architectural decisions and available alternatives to choose which style is better.
But counting is hardly the right metric – not every decision point has the same
weight. Second, most decision points on every level have two options, one for each
style, indicating that they actually have nothing in common. Only in a few cases do
both styles require a decision on the same question. Nevertheless, this paper is the
best-conducted comparison of principles available today. It’s unbiased, thoroughly
researched, and it examines multiple points of view.
Richardson and Ruby book. A second comparison of note is presented in
the book, “RESTful Web Services” (Richardson and Ruby 2007). The authors,
Richardson and Ruby, discuss the principles that are relevant to all systems available
on the Web. Even though their book is biased toward RESTful Web services, the
principles they discuss would be a better starting point for making a fair comparison
between the two styles.
They identify four system properties of RESTful services: (1) uniform interface,
(2) addressability, (3) statelessness, and (4) connectedness. In RESTful Web
services, these properties are embodied in resources, URIs, representations, and the
links between them. Lets consider how these principles apply to WS– services.
Addressability and some form of connectedness are embedded in the WSDL
definition of bindings and ports. Many WS-*services are stateless (although it is
not an explicit requirement). Having a uniform interface shared by all services is
the only property not supported by WS–. Thus, WS– services exhibits three of
these four properties. WS– services achieve these properties via different means,
but these properties are clearly relevant to both, and therefore a good choice for
comparison.
Richardson and Ruby use a similar approach to evaluate how RESTful Web
services offer capabilities which are important for enterprise-level integration. They
show how to implement transactions, reliability, message-level security (concepts
that Pautasso et al mention, but do not discuss) using REST. We will return to these
three concepts in “Ready for the Enterprise?”.
Both styles of Web services possess certain characteristics that guide their design
and development, although they are defined in ways that make it difficult to compare
them side-by-side. Next, we will look at how services are used in practice, which
provides yet another perspective for comparing them.
One obstacle to studying existing Web services is the fact that many of them
are not accessible to the outside world, because they are proprietary. Proprietary
systems have different requirements (fewer security threats due to well known
vulnerabilities, no need to adhere to common standards) that result in different
choices of Web services technologies. Industry studies provide some insight about
40 P. Adamczyk et al.
the trends in proprietary Web services, such as the planned and actual usage of
Web services. One industry survey shows that the adoption of SOAP standard by
enterprises increased 31% between 2002 and 2003 (Correia and Cantara 2003).
A follow-up survey from 2006 notes that about 12% of enterprises report completing
a “full enterprise roll-out” and another 21% are in process, while 60% are still
studying the feasibility of such projects (McKendrick 2011). Both surveys report
only on WS– Web services.
More recent results show a new trend. According to a 2008 Gartner
Survey (Sholler 2008) there has been an increase in the number of organizations
implementing Web services using Representational State Transfer (REST) and
Plain Old XML (POX). RESTful Web services are considered less complex, require
fewer skills, and have a lower entry cost than WS– Web services. However, the
surveyors believe that RESTful services by themselves do not provide a complete
enterprise solution.
Turning our attention to public Web services, two earliest surveys of public Web
services (Kim and Rosu 2004; Fan and Kambhampati 2005), from 2004, discussed
strictly WS– services. Both surveys showed that some of WS– standards (most
notably SOAP and WSDL) were successfully used in practice, but they did not
cover other standards. These surveys have been limited to WS– services, perhaps
unintentionally, because they considered the presence of a WSDL file as a necessary
prerequisite of a valid Web service.
In order to build on their work, we have studied various Web services repositories
(including the only extant ones cited by these surveys) to analyze the available
public Web services from the perspective of architectural styles they follow. We
performed these surveys in mid-2007 and again in mid-2010 by examining the Web
services listed in the following repositories:
• xmethods.net
• webservicex.net
• webservicelist.com
• programmableweb.com
These repositories describe only publicly accessible Web services. While SOAP
services are easy to find automatically (by checking for the presence of the WSDL
file), RESTful services are documented in non-standard ways that make their
automatic discovery impossible. We examined the type of each service manually,
by reading its documentation. We have identified four mutually exclusive categories
of Web service styles: RESTful, WS–, XML-RPC, and Other. XML-RPC was the
first attempt at encoding RPC calls in XML (which later evolved into SOAP). The
Other category groups many other types of services, including RSS feeds, Atom,
XMPP, GData, mail transfer protocols. The most popular styles of Web services in
each repository are shown in Table 2.1.
At a first glance, these results could not possibly paint a more inconsistent
picture. Each repository shows a different trend. However, the differences arise from
the nature/focus of these repositories. The first two repositories, which list (almost)
exclusively WS– services, advertise services that require payment for access. The
2 REST and Web Services: In Theory and in Practice 41
second repository appears to be closed to registration (we could not find any way
to contact the owners to register a new service) which may imply that they are
advertising only the services which they own. The numbers of services listed in
these two repositories have not changed much in the last 3 years.
The latter two repositories feature a variety of Web service styles, with RESTful
and WS– services being the two most popular styles in both the 2007 and 2010
tally. Programmableweb.com is the only repository that shows an increase in the
number of services; a fivefold increase over the observed period. Its data shows
increase in all types of services, but mostly in RESTful ones, which currently
account for about 75% of services listed, compared to less than 50% 3 years earlier.
These results, although insufficient to determine conclusively which style is more
popular (and why), indicate that a wide variety of public Web services is available
and that a sizable number of RESTful services has been created recently, even if not
all of them are widely known.
With so many public Web services available to study, we were able to identify many
trends in how closely services follow the theoretical principles of REST. WS–
principles are encoded in XML-based standards that are easy to enforce by tools.
The designer selects the necessary features (standards), then finds the tool that
supports them. The actual development is easy. But since this book is about REST,
we will focus on RESTful Web services, and refer to WS– only to compare and
contrast specific features. In this section, we will review how REST principles are
embodied and implemented in actual RESTful Web services.
According to the principles of REST, which we introduced in “Web Services in
Theory”, every resource is identified with a URI. In response to HTTP messages,
resources return their representations to clients, or the clients modify the resources.
42 P. Adamczyk et al.
Fig. 2.1 Examples of RESTful hypermedia defined as URIs. Examples 1–5 use query strings of
form key=value. Examples 4a–c show alternative ways to define the same resource. Example 6
uses the structural form instead of query strings: the order of keywords is defined by the server’s
API so that the client need not list keys, only values, in the URI
Proponents of RESTful Web services typically say that every service needs to follow
the CRUD model (Kilov 1990). This concept, borrowed from the database domain,
defines one method for creating, reading, updating, and deleting a resource on the
server (corresponding to POST, GET, PUT, and DELETE methods). This approach
enables invoking different operations on a resource by applying a different HTTP
method. This is only possible if resources are defined in a correct way. Figure 2.1
shows some examples of valid URIs. All of these URIs can be accessed with the
GET method.
One good example of a Web service that follows the principles of REST is Ama-
zon S3 (Simple Storage Service) (Amazon 2011). S3 defines many resources and
uses HTTP methods (POST, GET, PUT, DELETE, even HEAD) for manipulating
them. It uses HTTP error codes correctly and shows how to map various errors
to HTTP codes (the API references 13 unique HTTP status codes in the 300–500
range). S3 also supports caching by including ETag header that clients can use in
conditional GET.
However, most RESTful services are not designed as diligently. They neglect
to follow the principles in various ways. In order to evaluate the current level of
understanding of REST, we will look at some representative mistakes from the
perspective of the 4 principles of REST.
2 REST and Web Services: In Theory and in Practice 43
Identification of Resources
Every designer of a RESTful service must answer the question: What constitutes
the resources of the system? Ideally, any concept within the system that has a
representation should be exposed as a resource.
In WS– services, clients invoke API methods on the server by passing SOAP
messages to a well-known service end-point defined with a URI. These service
end-points are the only resources used by WS–. Some RESTful service follow
the same pattern – they define one path component to be used in every URI and
encode parameters for the corresponding server method in the query strings. This is
wrong, because in REST resources are supposed to be accessed with self-descriptive
messages (e.g. HTTP methods) that have well-defined semantics. Looking at
Example 5 in Fig. 2.1, it’s OK to access this resource via GET, but what would be
the intended semantics for PUT and other HTTP methods? Such a resource can only
accept read-only requests, the way Google’s search service works. But if the clients
need to be able to modify the resources, this style of resources is not appropriate.
Defining resources is hard. Consider, for example, a hypothetical Web service
that provides information about books and music. Such a service should define
multiple resources, book, cd, review that are queried by title, author, or ISBN.
Example 1 in Fig. 2.1, example.org/book?title=zen represents a resource
for books that contain “zen” in the title. Examples 2 and 3 show how to query
the resource by author and ISBN. There are several options for defining resources
corresponding to a review. The system could have one review resource (as in 4a), a
dedicated resource for each product type (in 4b), or a composite resource (review)
with individual children resources, one per product type (4c). These all are valid
choices. Alternatively, as in Example 6, the URI structure can enforce a specific
order of parameters (type, then title, then author), thus making it unnecessary to
specify the type of each sub-element in the URI. Note that this format requires
implicit understanding of the structure of this URI, which is defined outside of the
URI by the provider of this Web service.
The problem of designing resources is similar to teaching object-oriented design
to programmers, who were first taught procedural languages – it requires a changed
mindset. One can define resources without deep understanding of REST, but it’s
unlikely that such design will take full advantage of all available features of HTTP
and URI standards as objects/classes. In the second step, the public methods of the
object are defined. In any non-trivial problem, these two steps identify many objects
and many methods. The application is built by connecting the objects, which invoke
methods on one another. A similar approach can be applied to defining resources,
except that only the first step identifies many objects (i.e. resources). The available
HTTP methods are defined in the standard and links between resources are traversed
at run-time. Thus steps 2 and 3 come for free in HTTP, but only if step 1 is done well.
44 P. Adamczyk et al.
Representations
Self-descriptive Messages
1
GET sends data from the server to the client, in the response. POST sends the data from the client
to the server, in the request. Thus, GET is used for reading, and POST for writing.
2
A simple bank transaction, e.g. transferring $100 from savings to checking, involves sending
four HTTP requests. First, create a resource for the transfer using POST. Next, send a PUT to the
2 REST and Web Services: In Theory and in Practice 45
to encode more complex operations (such as “search”) into URIs in RPC style even
though they know that it violates REST. Another reason why the CRUD metaphor
is not a good match is that HTTP methods POST and PUT do not map exactly to
CRUD’s “create” and “update,” respectively. PUT carries a representation produced
by the client, which the server should use to replace its contents (so it serves as both
create and update). POST means the server decides how to use the representation
submitted by the client in order to update its resource.
This problem of not taking full advantage of HTTP methods is not unique to Web
services. Typical Web applications (accessible via browsers) use only two HTTP
methods in practice. In a study of HTTP compliance of Web servers (Adamczyk
et al. 2007), we found that Web servers and intermediaries understand correctly
only GET and POST methods. Only a fraction of popular websites send compliant
responses to other HTTP methods, even though the popular Web servers implement
all these methods correctly. These compliance results haven’t changed much since
HTTP/1.1 standard has been released, in 1999.
The inclusion of the 4 HTTP methods corresponding to CRUD operations in a
definition of a RESTful service is only a first step in satisfying the principle of self-
describing messages. This principle means that methods should be used according
to their standard definitions. A case in point is the new HTTP method, PATCH,
added in March 2010 (Dusseault and Snell 2010). It is intended to complement
PUT and replace some uses of POST with more precise semantics. With POST, the
client cannot specify how the resource is to be updated. Unfortunately, the definition
of PATCH does not define the structure for including the instructions to update
(i.e., patch) the resource. A standard definition of the instructions will be necessary
to make this method interoperable. As the additions of PATCH indicates, the set
of relevant HTTP methods is not static. The WebDAV protocol (which RESTful
proponents tend to overlook) defines 8 more methods for distributed authoring and
manipulating collections of resources (Goland et al. 1999). Thus RESTful Web
services have many self-describing methods to choose from. Although today most
Web services don’t use their HTTP methods right, we hope that in time they will.
HATEOAS
Hypermedia as the engine of application state means that neither client nor server
needs to keep the state of the exchange in a session, because all the necessary
information is stored in the exchanged HTTP messages (in the URI and the
accompanying HTTP headers and body). Defining self-contained links is critical for
RESTful Web services, because these links make it possible to traverse, discover,
and connect to other services and applications.
resource specifying the withdrawal of $100 from savings. Then, send a second PUT to deposit
$100 to checking. Finally, send a PUT to commit the transaction. Note that the burden of verifying
that each step was successful is on the client. If a step fails, the client needs to send a DELETE to
the transaction resource to abort the transaction (Richardson and Ruby 2007).
46 P. Adamczyk et al.
The HTTP standard defines the meaning of different error conditions and several
mechanisms for caching. Compliant RESTful Web services should follow them.
Initially, RESTful services copied their error-handling mechanism from SOAP.
Many Web services would not use HTTP status codes (e.g. “404 Not Found”)
to describe the result of a request, but rather always returns “200 OK” with the
actual status is hidden in the response body. Other services (e.g. earlier versions of
Yahoo Web services) defined their own status codes that were incompatible with
the standard ones. By using service-specific codes, they would not take advantage
of existing Web systems that understand these codes thus forcing clients to build
specialized, non-interoperable software to handle them. Fortunately, most Web
services we surveyed now do use HTTP status codes, and only add service-specific
extensions for new statuses. For example, Delicious uses codes 500 and 999 to
indicate that user request was throttled (due to exceeding a pre-defined limit of
connections). HTTP does not have a status that corresponds to this condition, so
it makes sense to define a new one.
Our survey gathered little information about caching. Aside from exceptional
Web services like S3 (and even they don’t use the term caching in the documen-
tation), RESTful services do not document if they support caching. Of course, the
services that employ user-ids could not benefit from caching anyway.
As the length of this section indicates, RESTful services still have difficulty in
following the principles of REST. There are few fully compliant service definitions,
but it’s easy to find examples of services that violate any of the principles. On the
bright side, we have observed a lot of improvements in compliance over the last
few years. RESTful services, by the virtue of being public are more open to general
2 REST and Web Services: In Theory and in Practice 47
scrutiny. Users can discuss the design decisions in the open, criticize them, and see
changes in the next version. To gain a better perspective of the positive changes that
occurred over the years, the reader is encouraged to browse the discussion of these
and other violations documented at RESTWiki (2011).
An important question is: Why are many services that attempt to be RESTful not
compliant with the principles of REST? Are these principles too restrictive? Too
hard to implement? Unnecessary for Web services (as opposed to Web pages and
Web applications)? It’s still too early to tell.
Many frameworks and tools for building RESTful Web services are available today.
They are written in different programming languages and range from simple to
quite sophisticated in their support of HTTP and other Web technologies. As they
continue to improve, misunderstandings and violations present in today’s Web
services will likely lessen.
We have examined ten popular frameworks that provide automated support for
building software according to the principles of REST. Some frameworks, like
Ruby on Rails and Spring are generic Web frameworks, while others are specific
to RESTful services. Table 2.2 summarizes key features of these frameworks,
grouped by REST principles. The frameworks are listed alphabetically, sorted by the
programming language and name. The second column in the table shows how these
frameworks support defining resources (corresponding to REST principles 1 and 4).
Almost all the frameworks provide some support for building resources (URIs) and
hyperlinks – through URI templates (Gregorio et al. 2010), annotations in the target
programming language, or other types of mappings. The third column shows which
types of multimedia are supported and how (principle 3). Most frameworks enable
generation of multiple representation formats. The fourth column shows which
HTTP methods are supported (principle 4). Most of them support GET, POST, PUT,
and DELETE HTTP methods, either directly, or by specifying the desired method in
an auxiliary parameter [such as the X-HTTP-Method Override header, or the
hidden “ method” form field (Richardson and Ruby 2007)]. The last column points
out other interesting features provided by the frameworks. Few brave frameworks
have ventured into implementing more advanced concepts of caching, automated
testing, or authentication.
48
Table 2.2 How frameworks for building RESTful Web services support the principles of REST
Other (API,
Name (Prog. Resources and caching, status
language) HATEOAS Representation Messages codes, etc.)
Jersey (Java) Annotations for URI MIME types, XML, GET POST PUT Support for JAX-RS. Testing
mappings JSON and Atom DELETE framework
RESTEasy (Java) Annotations for URI Annotations for output GET POST PUT Output caching and
translations and representations (many DELETE compression Support for
variable mapping types supported). JAX-RS
Content negotiation
Restlet (Java) URI templates and Supports various output GET POST PUT Support for JAX-RS.
variable binding representations DELETE Caching headers set in
Conditions class.
Security checks added
via filters. All HTTP
status codes
Spring (Java) Templated URIs using Content negotiation with GET and POST ETag header for caching
Java annotations Accept header or by directly, PUT
URL inspection (read and DELETE
file extension) with
_method
Recess (PHP) URI templates and Not supported GET POST PUT Not supported
variable extraction DELETE
using annotations
Routes (Python) Proper URL syntax; Not supported GET POST PUT Not supported
No IDs in query DELETE
P. Adamczyk et al.
parameters
CherryPy (Python) Simple mapping: HTML forms GET and An object tree generated to
HTML forms POST map requests to Python
to Python variables functions
Django (Python) URI templates for Targeted output GET POST Caching. HTTP status codes
mapping advanced formats: XML, JSON, PUT supported by Python
URL patterns to YAML DELETE libraries
Python code
RESTfulie (Ruby, emphasizes many formats; content GET POST HTTP status codes;
Java) hypermedia negotiation PUT integrates with Ruby on
links DELETE Rails
Ruby on Rails Route configs map URI Excellent support of GET POST Conditional GET for caching
(Ruby) to Component many data formats – PUT RESTful authentication
class (imposes URI e.g. Accept header DELETE
conventions)
2 REST and Web Services: In Theory and in Practice
49
50 P. Adamczyk et al.
Several of the Java frameworks support JAX-RS, a Java API for RESTful Web
services. They are Jersey (considered the reference implementation), Restlet, and
RESTEasy. JAX-RS specifies how to map Java classes to Web resources using Java
annotations. The annotations specify the relative path of the resource (part of the
URI) for a Java class, which Java methods correspond to HTTP methods, which
media types are accepted by the class, and how to map class properties to selected
HTTP headers (Hadley and Sandoz 2009).
Aside from Django, all the Python and PHP frameworks offer only rudimentary
support for REST. Other frameworks include more advanced features, but they still
fall short of supporting all principles of REST. Most frameworks define schemes
for mapping URIs to classes and methods, but not all of them are as flexible as
HTTP requires, e.g. Ruby on Rails imposes constraints on URI formats. Only one
framework (Restlet) supports all HTTP status codes. No framework supports all
flavors of HTTP caching, and many do not support caching at all.
The principle of HATEOAS (unambiguous semantics for following and em-
bedding links) is not well supported. Only the RESTfulie framework emphasizes
the importance of this principle. Let’s consider a simple example of the expected
behavior. When a client requests a resource (e.g. information about a collection
of items) it should be easy to construct a URI to refer to an individual item from
that collection. Frameworks should provide built-in support for such conversions of
URIs. Currently, this mapping work must be implemented manually in the client
code, because most frameworks do not support it.
Overall, the RESTful frameworks need to include more functionality to be fully
compliant with REST. But the biggest problem is that even if they do implement
the support for a principle, the frameworks have no mechanisms to enforce that it is
applied correctly in the client code.
Frameworks make it possible to build bigger Web services, and their capabilities
keep on growing. Is that enough to persuade enterprise system architects to switch
to RESTful Web services? Recall the study of Web services by Pautasso et al.
(2008) we discussed in “Web Services in Theory”. They cite security, reliable
messaging and transactions as key differentiators between RESTful and WS–
services. To be ready for enterprise, RESTful frameworks need to support these
features. Richardson and Ruby (2007) show how these concepts can be implemented
using HTTP.
For basic message-level security, it’s enough to use HTTPS. But more complex
capabilities such as signatures, encryption, or federation (enabling a third party to
broker trust of identities) cannot be supplied by HTTP alone. Further research is
required to define these concepts properly in RESTful Web services (more about
this in “Open Research Problems of RESTful Services”.)
2 REST and Web Services: In Theory and in Practice 51
To provide reliable messaging, one needs to ensure that all HTTP methods are
idempotent. This property makes it possible to replay any method, as necessary,
to make sure that it succeeded. Of course, this approach to reliable messaging is
tedious and currently requires a lot of manual coding on the client side.
Implementing transactions with HTTP messages requires exchanging many
messages, which can get complex quickly (as we saw in “Self-descriptive Mes-
sages”). Current frameworks are not mature enough to abstract out/encapsulate
common transaction patterns. But transactions are needed as building blocks of
workflows, which occur often in enterprise systems. A proposed extension to the
Jersey framework introduces action resources for specifying workflows (Hadley
et al. 2010). Each action resource exposes one workflow operation available on
the service. The client obtains the workflow specification (i.e. the list of action
resources) at the beginning of the sequence. In line with the principle of HATEOAS,
it’s the client’s responsibility to keep track of the current state of the system
throughout the execution in order to invoke the workflow resources in the correct
order. This is a dynamic approach, because the exact sequence of the workflow
need not be specified until the client begins to execute it.
But even if security, reliable messaging, and transactions are solved successfully,
RESTful services must also demonstrate scalability. Compared to large legacy
systems on top of which many WS– services are built, current RESTful services
are small. Tool support is needed for combining disparate services to build larger
ones and for automating the generation of URI schemas that can adapt when a
service is being extended.
Today’s frameworks are not yet ready to support enterprise needs. They do
not implement advanced security features or transactions; they do not verify that
HTTP methods they generate are idempotent, which is the necessary prerequisite
for reliable messaging; they are not scalable. Implementing these features is a
matter of time, because HTTP already defines most of the necessary concepts to
perform these tasks. However, it’s not enough that the frameworks implement the
necessary functionality. The frameworks must guide and force the users to recognize
the correct features for the job and to apply them correctly.
Proponents of RESTful Web services made their first attempts to reach the
research community via conference presentations (Prescod 2002; Haas 2005),
and computer magazine editorials (Vinoski 2008). Recently, survey papers
(Pautasso et al. 2008), and new research work (Pautasso et al. 2010; Overdick 2007)
began to appear. Hopefully, this book will advance the state of research even farther.
The problems we discuss below are concerned with non-functional requirements
and how they can be supported by RESTful services. Many of these research efforts
are defining new Web standards. Web linking (Nottingham 2010) aims to improve
cache invalidation. HTTP PATCH (Dusseault and Snell 2010) defines a new method
to make more maintainable services. URI templates (Gregorio et al. 2010) make
it easier to define groups of resources with regular expressions. OAuth (Hammer-
Lahav 2010) secures authentication and data sharing in HTTP-based systems.
Caching
Maintainability
Typical maintenance tasks of Web services (adding new features, fixing service
APIs) affect services themselves, their documentation, the client code, and even
the development tools. Since RESTful Web services are still prone to wholesale
changes, each of these facets offers ample opportunities for research.
2 REST and Web Services: In Theory and in Practice 53
Changes of Web service definitions necessitate upgrades of the client code. When
a new version of a service becomes available, clients need to adapt their code.
Neither WS– nor RESTful services providers are concerned with making client
updates easier. They claim that there is no need to deprecate APIs, because they
will always be available, so clients are not required to upgrade. Ideally, this would
be the case, because well-named resources do not need to change (Berners-Lee
2011). New Web services might be able to preserve their APIs for some time, but
maintaining several versions isn’t realistic if a service plans to grow. Some services
offer software development tools for building client applications, but they suffer
from the same types of challenges as typical software – APIs change. Is it time to
start exploring refactoring of Web service APIs?
Storing URIs in web logs may lead to privacy problems if the logs are not
protected and anonymized. WS– services do not store sensitive data in HTTP
method signature and query strings. On the other hand, URIs created for RESTful
Web services become the audit trail, and they should be anonymized.
Figure 2.2 illustrates a hypothetical model of how the security and privacy
measures can be applied together. It shows a secure token service, a key entity in
a third party authentication model. Note that the figure does not define the actual
steps of an ideal protocol; it is an open research problem. Researchers also need to
figure out how the security measures fit the REST model.
QoS
When multiple providers offer the same service, a client has a choice and can select
the most suitable one. Often, this choice comes down to the Quality of Service
(QoS) parameters. RESTful Web services today ignore QoS requirements; their
only concern is providing functional interfaces. To add QoS parameters to RESTful
services, a language for describing the parameters and a mechanism to incorporate
the description in the HTTP payload is needed. Defining a standard QoS description
language might benefit from the work in Semantic Web. Semantic Web ontologies
define standard ways of interpreting information, such as QoS parameters, enabling
all clients to interpret them the same way.
2 REST and Web Services: In Theory and in Practice 55
Web services are good candidates for studying how software engineering concepts
are followed in large, publicly available systems. But there have been few successful
studies of RESTful services, or side-by-side comparisons of a service that exposes
two interfaces defined in the competing styles (one RESTful, one WS–).
It is not easy to compare these two styles at the level of principles. The first
order of research is to identify good principles for making the comparison. Zarras
(2004) identifies the following principles for comparing middleware infrastructures:
openness, scalability, performance, and distribution transparency. Properties of
software architectures (Bass et al. 2002) is another source of principles to consider.
Another possibility is to apply the same principled approach Fielding used to derive
REST in order to define both RESTful and WS– architectural styles. This would
entail selecting and applying additional constraints, one at a time, to derive complete
definitions of both architectural styles.
Conclusion
RESTful Web services (and Web services in general) pose the first serious test of
the principles of REST, as identified by Fielding. On the one hand, the emergence
of RESTful Web services, in response to WS– services can serve as an indication
that REST is the correct architecture for the Web. On the other hand, the state of
practice still shows gaps in understanding and applying the theory behind REST,
thus indicating that the process is not complete.
Up until a few years ago, there was a simple dichotomy between REST
and WS–. RESTful services were used only for simple, public services. In
contrast, enterprise standards, tools vendors, and the research community were only
concerned with WS– services. This is no longer the case – both styles are being
used in all domains. The new challenge is to use them correctly, and to be able
to align them to solve the real problems of the enterprise. Can RESTful services
scale up to the enterprise-size challenges? We believe so. Amazon, Google, Yahoo,
Microsoft, and other big companies have been building large, scalable, extensible,
and relatively secure systems on the Web. RESTful services have the same basic
principles to follow.
This concludes our whirlwind overview of how Web services relate to REST, in
theory and in practice. Other chapters in this book will explore these topics in more
details.
Acknowledgements The authors would like to thank Nicholas Chen, Hakan Erdogmus, Jim
Webber, and anonymous reviewers for reviewing earlier drafts of this work.
56 P. Adamczyk et al.
References
L. Bass and P. Clementes and R. Kazman. Software Architecture in Practice, 2nd Edition. Addison
Wesley, 2002.
P. Adamczyk, M. Hafiz, and R. Johnson. Non-compliant and Proud: A Case Study of HTTP
Compliance, DCS-R-2935. Technical report, University of Illinois, 2007.
Amazon. Amazon Simple Storage Service API Reference, May 2011. http://docs.
amazonwebservices.com/AmazonS3/latest/API/
Apache HTTP Server v2.2. Authentication, authorization and access control, May 2011. http://
httpd.apache.org/docs/2.2/howto/auth.html.
T. Berners-Lee. Cool URIs don’t change, May 2011. http://www.w3.org/Provider/Style/URI.html.
T. Berners-Lee, R. Fielding, and H. Frystyk. RFC 1945: Hypertext Transfer Protocol — HTTP/1.0,
May 1996.
J. Correia and M. Cantara. Gartner sheds light on developer opps in web services. Integration
Developers News, June 2003.
Dare Obsanjo Blog. Misunderstanding REST: A look at the Bloglines, del.icio.us and Flickr APIs,
May 2011. http://www.25hoursaday.com/weblog/PermaLink.aspx?guid=7a2f3df2-83f7-471b-
bbe6-2d8462060263.
B. M. Duska, D. Marwood, and M. J. Freeley. The measured access characteristics of World-Wide-
Web client proxy caches. In USENIX Symposium on Internet Technologies and Systems, USITS,
1997.
L. Dusseault and J. Snell. RFC 5789: PATCH Method for HTTP, Mar. 2010.
J. Fan and S. Kambhampati. A Snapshot of Public Web Services. In SIGMOD Record, Vol. 34, No.
1, Mar. 2005.
R. Fielding. Architectural Styles and the Design of Network-based Software Architectures.
Doctoral dissertation. Technical report, University of California, Irvine, 2000.
R. Fielding, J. Gettys, J. Mogul, H. Frystyk, L. Masinter, P. Leach, and T. Berners-Lee. RFC 2616:
Hypertext Transfer Protocol — HTTP/1.1, June 1999.
B. Fitzpatrick. OpenID, 2005. http://openid.net/.
J. Franks, P. Hallam-Baker, J. Hostetler, S. Lawrence, P. Leach, A. Luotonen, and L. Stewart. RFC
2617: HTTP Authentication: Basic and Digest Access Authentication, June 1999.
J. Garrett. Ajax: A New Approach to Web Applications, Feb. 2005. http://adaptivepath.com/ideas/
essays/archives/000385.php.
Y. Goland, E. J. Whitehead, A. Faizi, S. Carter, and D. Jensen. HTTP Extensions for Distributed
Authoring WebDAV. Internet proposed standard RFC 2518, Feb. 1999.
J. Gregorio, R. Fielding, M. Hadley, and M. Nottingham. URI Template (draft), Mar. 2010.
H. Haas. Reconciling Web services and REST services (Keynote Address). In 3rd IEEE European
Conference on Web Services (ECOWS 2005), Nov. 2005.
M. Hadley, S. Pericas-Geertsen, and P. Sandoz. Exploring Hypermedia Support in Jersey. In WS-
REST 2010, Apr. 2010.
M. Hadley and P. Sandoz. JAX-RS: Java API for RESTful Web Services (version 1.1), Sept. 2009.
E. Hammer-Lahav. RFC 5849: The OAuth 1.0 Protocol, Apr. 2010.
I. Hickson. HTML5: A vocabulary and associated APIs for HTML and XHTML, Oct. 2010.
Joe McKendrick. Service Oriented Blog, May 2011. http://www.zdnet.com/blog/service-oriented/?
p0542.
H. Kilov. From semantic to object-oriented data modeling. In First International Conference on
Systems Integration, pages 385–393, 1990.
S. M. Kim and M. Rosu. A Survey of Public Web Services. In WWW 2004, 2004.
L. Richardson and S. Ruby. RESTful Web Services. O’Reilly, Oct. 2007.
M. Nottingham. HTTP Status Report. In QCon, Apr. 2009.
Meebo Dev Blog. Introducing XAuth, Apr. 2010. http://blog.meebo.com/?p=2391.
M. Nottingham. Web Linking (draft), May 2010.
H. Overdick. Towards resource-oriented BPEL. In C. Pautasso and T. Gschwind, editors, WEWST,
volume 313. CEUR-WS.org, 2007.
2 REST and Web Services: In Theory and in Practice 57
C. Pautasso, E. Wilde, and A. Marinos. First International Workshop on RESTful Design (WS-
REST 2010), Apr. 2010.
C. Pautasso, O. Zimmermann, and F. Leymann. RESTful Web Services vs. “Big” Web Services:
Making the Right Architectural Decision. In WWW ’08: Proceeding of the 17th international
conference on World Wide Web, pages 805–814, New York, NY, USA, 2008. ACM.
P. Prescod. Roots of the REST/SOAP Debate. In Extreme Markup Languages, EML, 2002.
E. Rescorla. RFC 2818: HTTP over TLS, May 2000.
RESTWiki, May 2011. http://rest.blueoxen.net/cgi-bin/wiki.pl.
D. Sholler. 2008 SOA User Survey: Adoption Trends and Characteristics, Sept. 2008.
S. Vinoski. Serendipitous reuse. IEEE Internet Computing, 12(1):84–87, 2008.
W3C Working Group Note. Web Services Architecture, May 2011. http://www.w3.org/TR/2004/
NOTE-ws-arch-20040211/.
Web Service Security (WSS). Web Services Security: SOAP Message Security 1.1, Feb. 2006.
A. Zarras. A comparison framework for middleware infrastructures. Journal of Object Technology,
3(5):103–123, 2004.
http://www.springer.com/978-1-4419-8302-2