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 explAdvance Praise for rest in practiceJim, Savas, and lan manage to make the notoriously abstract concepts behind RESTful integration useful and applicable in day-to-day work, as well as easy to understand If you'relooking into how to do web-based integration simply and effectively, this is where youshould startMark NottinghamPrincipal Technical Yahoo!, YahooIt is no coincidence that since jim, Savas, and ian started their frequent presentations andwritings on the importance and applicability of hypermedia in distributed systems, the landscape of reSt's practical usage started to change. Restfulie is an example how influential theirideas have beenGuilherme SilveiraTech Lead at Caelum and Restfulie Project LeaderwhilEtherearebynowmanybooksthatdescribebasicrestandhttpprinciplesthisbookraises the bar by exploiting the web architecture's benefits for more advanced use cases, suchas hypermedia-driven processes. a perfect mix of theory and practice-Stefan TilkovCEO. InnoQREST is different from traditional approaches to application design and development. It'mportant to clearly understand rest and build on successful examples. rest in Practice meetsthis need head-on. Its authors are all excellent technologists and communicators, and havedone a great job tackling this challenging subjecterIC Newcomerchief Architect, Investment Banking Division, Credit Suisse"RESt in Practice unifies a grounded, pragmatic approach to building real-world services withcrystal-clear explanations of higher-level abstractions. The result is a book that teaches youboth how and why to develop services with flexible, negotiable, discoverable interfacesMichaeL nAuthor of release /t/REST can appear confusing and inaccessible, filled with jargon and with precious few reallygood examples. Luckily, this book does a superb job of taking the difficult and misunderstoodparts of Rest and describing them so they appear both simple and obvious. Along the way, italso shows how to build upon REST and the Web to solve real-world problemsColin jackSenior Software DeveloperREST in practiceJim webber savas parastatidis, and lan robinsonO'REILLYBeijing· Cambridge Farnham Koln· Sebastopol· TokyoREST in practiceby jim Webber, Savas Parastatidis, and Ian robinsonCopyright o 2010 Jim Webber, Savas Parastatidis, and Ian robinson. All rights reservedPrinted in the united states of americaPublished by o'reilly media, Inc. 1005 Gravenstein Highway North, Sebastopol, CA95472O'Reilly books may be purchased for educational, business, or sales promotional use Onlineeditionsarealsoavailableformosttitles(http://my.safaribooksonline.com).Formoreinformationcontactourcorporate/institutionalsalesdepartment:(800)998-9938orcorporate@oreilly.comEditor: Simon St laurentIndexer: Lucie haskinsProduction Editor: Rachel MonaghanCover Designer: Karen montgomeryCopyeditor: Audrey doyleInterior Designer: Ron BilodeauProofreader: Rachel Monaghanllustrator: robert romanoProduction services:Newgen North AmericaPrinting HistorySeptember 2010First editionThe O'reilly logo is a registered trademark of O'Reilly media, Inc, REST in Practice, the coverimage and related trade dress are trademarks of o'reilly media, IncMany of the designations used by manufacturers and sellers to distinguish their products areclaimed as trademarks. Where those designations appear in this book, and o'reilly media, Inc,was aware of a trademark claim, the designations have been printed in caps or initial capsWhile every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use ofthe information contained hereinISBN:978-0-596-80582-1CONTENTSForewordPrefaceXThe Web as a platform for Building distributed Systems.. 1Architecture of the webThinking in ResourcesFrom the Web architecture to the rest Architectural Style 12The Web As an Application PlatformWeb Friendliness and the richardson Maturity model18GET on board202 Introducing Restbucks: How to GET a Coffee,Web style21Restbucks: A Little Coffee Shop with Global Ambitions 22Toolbox27Here comes the web3 Basic Web IntegrationLose Weight, Feel greatA Simple coffee ordering systemURI TemplatesURI TunnelingPox: plAin old Xml over Http42We Are Just Getting Started544 CRUD Web services55Modeling Orders As resources55Building CRUd ServicesAligning Resource StateConsuming CrUd services83Consuming services automatically with WADLCRUD IS Good, but it's not great905 Hypermedia Services93The Hypermedia Tenet93Hypermedia Formats97Contracts108Hypermedia Protocols112Implementing a Hypermedia ServiceBuilding the Ordering Service in Java128Building the Ordering Service in. NET140Ready, Set, Action1526 Scaling out.155GET Back to basics155Caching157Making content Cacheable16lImplementing Caching in. NET167Consistencyl71Extending fresh179Stay Fi1837 The Atom Syndication Format185The Format185Common Uses for atom188USing Atom for Event-Driven Systems189Building an Atom Service in Java207Building an Atom Service lrNET21Atom Everywhere?234After the event2368 Atom Publishing protocol237Atom Publishing Protocol238Implementing Order Fulfillment Using AtomPub249Implementing Atom Pub in. NET268A Versatile protocol2839 Web security285Http Security essentials286Identity and the openID Protocol295The oauth protocol315Service hacks and defenses339Final thoughts349VI CONTENTS10 Semantics351Syntax Versus Semantics351Structure and representation of Information352The Semantic Web357Microformats372Linked data and the web373Guidance37411 The Web and ws-*375Are Web services evil?375SOAP: The Whole truth376WSDL: Just Another object IDL380Two Wrongs Don't Make a Right386Secure, Reliable, Transacted387A Requiem for Web services?40512 Building the Case for the Web407No More silver bullets407Building and running Web-Based Services407No Architecture Without measurement409Selling the webGo Forth and build414Index415CoNTENTs vii