Chapter 4. CRUD Web Services
IN THE PRECEDING CHAPTER, we saw how GET and POST
can be used to tunnel information to remote services through URIs and how
POST can be used to transfer XML
documents between services. However, as more interesting distributed
system scenarios emerge, we rapidly reach the limit of what we can
accomplish with those verbs. We need to expand our vocabulary in order to
support more advanced interactions.
In this chapter, we’ll introduce two new HTTP verbs to our
repertoire: PUT and DELETE. Alongside GET and POST,
they form the set of verbs required to fully support the Create, Read,
Update, Delete (CRUD) pattern for manipulating resources across the
network.
Note
From here onward, we consider the network and HTTP as an integral part of our distributed application, not just as a means of transporting bytes over the wire.
Through CRUD, we’ll take our first steps along the path to enlightenment using HTTP as an application protocol instead of a transport protocol, and see how the Web is really a big framework for building distributed systems.
Modeling Orders As Resources
In Restbucks, orders are core business entities, and as such, their life cycles are of real interest to us from a CRUD perspective. For the ordering parts of the Restbucks business process, we want to create, read, update, and delete order resources like so:
Orders are created when a customer makes a purchase.
Orders are frequently read, particularly when their preparation status is inquired.
Under certain ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access