REST in Practice

Book description

Why don't typical enterprise projects go as smoothly as projects you develop for the Web? Does the REST architectural style really present a viable alternative for building distributed systems and enterprise-class applications?

In this insightful book, three SOA experts provide a down-to-earth explanation of REST and demonstrate how you can develop simple and elegant distributed hypermedia systems by applying the Web's guiding principles to common enterprise computing problems. You'll learn techniques for implementing specific Web technologies and patterns to solve the needs of a typical company as it grows from modest beginnings to become a global enterprise.

  • Learn basic Web techniques for application integration
  • Use HTTP and the Web’s infrastructure to build scalable, fault-tolerant enterprise applications
  • Discover the Create, Read, Update, Delete (CRUD) pattern for manipulating resources
  • Build RESTful services that use hypermedia to model state transitions and describe business protocols
  • Learn how to make Web-based solutions secure and interoperable
  • Extend integration patterns for event-driven computing with the Atom Syndication Format and implement multi-party interactions in AtomPub
  • Understand how the Semantic Web will impact systems design

Publisher resources

View/Submit Errata

Table of contents

  1. Foreword
  2. Preface
    1. Should I Read This Book?
    2. Should I Skip This Book?
    3. Resources
    4. What Did You Think About the Book?
    5. Errata
    6. Conventions Used in This Book
    7. Using Code Examples
    8. How to Contact Us
    9. Safari® Books Online
    10. Acknowledgments
  3. 1. The Web As a Platform for Building Distributed Systems
    1. Architecture of the Web
    2. Thinking in Resources
      1. Resources and Identifiers
      2. Resource Representations
      3. Representation Formats and URIs
      4. The Art of Communication
    3. From the Web Architecture to the REST Architectural Style
      1. Hypermedia
      2. REST and the Rest of This Book
    4. The Web As an Application Platform
      1. Technology Support
      2. Scalability and Performance
      3. Loose Coupling
      4. Business Processes
      5. Consistency and Uniformity
      6. Simplicity, Architectural Pervasiveness, and Reach
    5. Web Friendliness and the Richardson Maturity Model
      1. Level Zero Services
      2. Level One Services
      3. Level Two Services
      4. Level Three Services
    6. GET on Board
  4. 2. Introducing Restbucks: How to GET a Coffee, Web Style
    1. Restbucks: A Little Coffee Shop with Global Ambitions
      1. Actors and Conversations
      2. Boundaries
      3. The Menu
      4. Sample Interactions
        1. Customer–Barista
        2. Customer–Cashier–Barista
    2. Toolbox
      1. Restbucks Formats
      2. Modeling Protocols and State Transitions
    3. Here Comes the Web
  5. 3. Basic Web Integration
    1. Lose Weight, Feel Great!
    2. A Simple Coffee Ordering System
      1. Choosing Integration Points for a Service
      2. A Simple Service Architecture
    3. URI Templates
      1. Intuitive URIs
      2. From Intuitive URIs to URI Templates
      3. Using URI Templates
    4. URI Tunneling
      1. Is URI Tunneling a Good Idea?
    5. POX: Plain Old XML over HTTP
      1. Using XML and HTTP for Remote Procedure Calls
      2. POX Away!
        1. Server-side POX implementation in .NET
        2. Server-side POX in Java
      3. Client-Side POX Implementation
        1. Using the .NET WebClient to invoke the ordering service
        2. Using the Apache Commons HttpClient in Java
      4. XML-RPC
      5. What About When Things Go Wrong?
    6. We Are Just Getting Started
  6. 4. CRUD Web Services
    1. Modeling Orders As Resources
    2. Building CRUD Services
      1. Creating a Resource with POST
        1. Implementing create with POST
      2. Reading Resource State with GET
        1. Implementing read with GET
      3. Updating a Resource with PUT
        1. Implementing update with PUT
      4. Removing a Resource with DELETE
      5. Safety and Idempotency
    3. Aligning Resource State
    4. Consuming CRUD Services
      1. A Java-Based Consumer
      2. A .NET Consumer
    5. Consuming Services Automatically with WADL
    6. CRUD Is Good, but It’s Not Great
  7. 5. Hypermedia Services
    1. The Hypermedia Tenet
      1. Hypermedia As the Engine of Application State
      2. Loose Coupling
    2. Hypermedia Formats
      1. Hypermedia Dead Ends
      2. URI Templates and Coupling
      3. Selecting a Hypermedia Format
        1. Standard hypermedia formats
        2. Domain-specific hypermedia formats
      4. Processing Hypermedia Formats
        1. Media types
        2. A media type for Restbucks
        3. Why application/xml doesn’t help
        4. Media type design and formats
    3. Contracts
      1. Contracts Begin with Media Types
      2. Extending Contracts with Protocols
      3. HTTP Idioms
      4. Using Contracts at Runtime
    4. Hypermedia Protocols
      1. The Restbucks Domain Application Protocol
      2. Advertising Protocols with Hypermedia
      3. Dynamically Extending the Application Protocol
      4. Data Modeling Versus Protocol Hypermedia
    5. Implementing a Hypermedia Service
    6. Building the Ordering Service in Java
      1. Service Architecture
      2. Java Implementation
        1. Resources
        2. Representations
        3. Workflow activities
      3. Consumer-Side Architecture
      4. Java Consumer Implementation
    7. Building the Ordering Service in .NET
      1. The Restbucks .NET Hypermedia Framework
      2. An External DSL for Hypermedia Interactions
      3. Implementation Considerations for .NET
        1. Resource creation
        2. Main service logic
        3. Payment
        4. Delivery
    8. Ready, Set, Action
  8. 6. Scaling Out
    1. GET Back to Basics
    2. Caching
      1. Benefits of Caching
      2. Caching and the Statelessness Constraint
      3. Reasons for Not Caching
      4. Types of Caches
    3. Making Content Cacheable
      1. Response Headers Used for Caching
      2. Using Caching Directives in Responses
    4. Implementing Caching in .NET
    5. Consistency
      1. Using Validation
      2. Using Expiration
      3. Using Invalidation
    6. Extending Freshness
      1. Cache Channels
    7. Stay Fresh
  9. 7. The Atom Syndication Format
    1. The Format
    2. Common Uses for Atom
    3. Using Atom for Event-Driven Systems
      1. The Problem
      2. Reference Data
      3. Event-Driven Updates
      4. The Anatomy of an Event
      5. Solution Overview
      6. Link Relations
      7. Polling for Recent Events
      8. Navigating the Archive
      9. Caching Feeds
      10. Implementation Considerations
    4. Building an Atom Service in Java
      1. Server-Side Architecture
      2. Managing Feeds
      3. Java Implementation
        1. Using Jersey for HTTP connectivity
        2. Generating feeds with ROME
      4. Java Consumer Implementation
    5. Building an Atom Service in .NET
      1. Writing Feeds to Files
      2. Tasks
      3. Building Feeds
      4. Handling Requests
        1. Writing the response
      5. Implementing Conditional GETs
      6. Wiring It Up
    6. Atom Everywhere?
    7. After the Event
  10. 8. Atom Publishing Protocol
    1. Atom Publishing Protocol
      1. Overview
      2. When to Use AtomPub
      3. Anatomy of AtomPub
        1. Collections
        2. Members
        3. Category and service documents
      4. AtomPub Extensions to Atom
        1. app:edited
        2. app:control and app:draft
        3. edit and edit-media link relation values
        4. type parameters
      5. Concurrency Control
    2. Implementing Order Fulfillment Using AtomPub
      1. Overview
      2. Adding an Order to the Fulfillment Pipeline
      3. Beginning Fulfillment
        1. Failed reservation
        2. Try again
        3. Where are we?
      4. Completing the Protocol
      5. Exceptions
      6. Summary
      7. Implementing More Complex Protocols
    3. Implementing AtomPub in .NET
      1. Implementing AtomPub Collections and Members
      2. Using Collections and Members for Order Fulfillment
      3. Testing WCF REST Services
      4. WCF Service Implementation
    4. A Versatile Protocol
  11. 9. Web Security
    1. HTTP Security Essentials
      1. HTTP Authentication and Authorization
      2. Transport-Level Confidentiality and Integrity
      3. Network and Performance Considerations
    2. Identity and the OpenID Protocol
      1. Protocol Flow
      2. OpenID in Java
        1. An OpenID-enabled Java consumer
        2. Restbucks Java ordering service
        3. Java OpenID provider
      3. Practical Considerations for OpenID
    3. The OAuth Protocol
      1. The Next Best Thing to Free Coffee?
      2. Protocol Example
      3. Implementing OAuth in Java
        1. Coffee voucher service
        2. Restbucks payment service
        3. Restbucks customer
      4. Practical Considerations for OAuth
    4. Service Hacks and Defenses
      1. Denial of Service
      2. Keep Secrets Secret
      3. Act Defensively
      4. Less Is Best
      5. Defend in Depth
    5. Final Thoughts
  12. 10. Semantics
    1. Syntax Versus Semantics
    2. Structure and Representation of Information
      1. Data, Information, Knowledge
      2. Structure
      3. Interpretation
      4. Shared Understanding
      5. Semantics
    3. The Semantic Web
      1. RDF
      2. OWL
        1. The Restbucks ontology
      3. SPARQL
      4. RDFa
    4. Microformats
    5. Linked Data and the Web
    6. Guidance
  13. 11. The Web and WS-*
    1. Are Web Services Evil?
    2. SOAP: The Whole Truth
      1. The SOAP Processing Model
      2. Make Love, Not War
        1. Envelope
        2. Headers
        3. Body
        4. Intermediaries
        5. Faults
    3. WSDL: Just Another Object IDL
    4. Two Wrongs Don’t Make a Right
    5. Secure, Reliable, Transacted
      1. Security
        1. End-to-end model
        2. Securing long-lived conversations
        3. Issuing security tokens
        4. Federating identities
        5. Web services security: Sophisticated and robust, or complex and opaque?
      2. Web Security
        1. Federated authentication on the Web
      3. Reliable Messaging
        1. Reliability on the Web
      4. Transactions
      5. Web Transactions
        1. Un-transactions
        2. Respecting boundaries
    6. A Requiem for Web Services?
  14. 12. Building the Case for the Web
    1. No More Silver Bullets
    2. Building and Running Web-Based Services
    3. No Architecture Without Measurement
    4. Selling the Web
      1. Cost
      2. Mitigate Risk and Release Value, Early and Often
    5. Go Forth and Build
  15. Index
  16. About the Authors
  17. Colophon
  18. Copyright

Product information

  • Title: REST in Practice
  • Author(s): Jim Webber, Savas Parastatidis, Ian Robinson
  • Release date: September 2010
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596805821