21.01.2022 Views

Sommerville-Software-Engineering-10ed

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

532 Chapter 18 ■ Service-oriented software engineering

Restful API

Service

requestor 1

Figure 18.7 RESTful

and SOAP-based APIs

Resource

R

SOAP-based

API

Service

requestor 2

these services may be included. The requesting service may then process the

requests in its own way. Therefore, a request for weather information given a place

name that is not unique may return the URLs of all of the places that match the request.

For example:

http://weather-info-example.net/temperatures/edinburgh-scotland

http://weather-info-example.net/temperatures/edinburgh-australia

http://weather-info-example.net/temperatures/edinburgh-maryland

A fundamental design principle for RESTful services is that they should be stateless.

That is, in an interaction session, the resource itself should not include any state

information, such as the time of the last request. Instead, all necessary state information

should be returned to the requestor. If state information is required in later

requests, it should be returned to the server by the requestor.

RESTful services have become more widely used over the past few years because

of the widespread use of mobile devices. These devices have limited processing

capabilities, so the lower overhead of RESTful services allows better system performance.

They are also easy to use with existing websites—implementing a RESTful

API for a website is usually fairly straightforward.

However, there are problems with the RESTful approach:

1. When a service has a complex interface and is not a simple resource, it can be

difficult to design a set of RESTful services to represent this interface.

2. There are no standards for RESTful interface description, so service users must

rely on informal documentation to understand the interface.

3. When you use RESTful services, you have to implement your own infrastructure

for monitoring and managing the quality of service and the service reliability.

SOAP-based services have additional infrastructure support standards such

as WS-Reliability and WS-Transactions.

Pautasso et al. (Pautasso, Zimmermann, and Leymann 2008) discuss when

RESTful and SOAP-based should be used. However, it is often possible to provide

both SOAP-based and RESTful interfaces to the same service or resource (Figure

18.7). This dual approach is now common for cloud services from providers such as

Microsoft, Google, and Amazon. Service clients can then choose the service access

method that is best suited to their applications.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!