restful_web_services.pdf

(3152 KB) Pobierz
644992294 UNPDF
644992294.049.png
Other resources from O’Reilly
Related titles
Ajax on Rails
Capistrano and the Rails
Application Lifecycle
Learning Java
Learning Python
Rails Cookbook
Ruby Cookbook
Ruby on Rails: Up and
Running
Web Services on Rails
oreilly.com
oreilly.com is more than a complete catalog ofO’Reillybooks.
You’llalsofindlinkstonews,events,articles,weblogs,sample
chapters, and code examples.
oreillynet.com istheessentialportalfordevelopersinterestedin
openandemergingtechnologies,includingnewplatforms,pro-
gramming languages, and operating systems.
Conferences
O’Reillybringsdiverseinnovatorstogethertonurturetheideas
thatsparkrevolutionaryindustries.Wespecializeindocument-
ing the latest tools and systems, translating the innovator’s
knowledge into useful skills for those in the trenches. Please
visit conferences.oreilly.com for our upcoming events.
SafariBookshelf( safari.oreilly.com )isthepremieronlinerefer-
ence library for programmers and IT professionals. Conduct
searchesacrossmorethan1,000books.Subscriberscanzeroin
on answers to time-critical questions in a matter of seconds.
ReadthebooksonyourBookshelffromcovertocoverorsim-
ply flip to the page you need. Try it today for free.
644992294.053.png 644992294.054.png 644992294.055.png 644992294.001.png 644992294.002.png 644992294.003.png 644992294.004.png 644992294.005.png 644992294.006.png 644992294.007.png 644992294.008.png 644992294.009.png 644992294.010.png 644992294.011.png 644992294.012.png 644992294.013.png 644992294.014.png 644992294.015.png 644992294.016.png 644992294.017.png 644992294.018.png 644992294.019.png 644992294.020.png 644992294.021.png 644992294.022.png 644992294.023.png 644992294.024.png 644992294.025.png 644992294.026.png 644992294.027.png 644992294.028.png
RESTful Web Services
Leonard Richardson and Sam Ruby
Beijing
Cambridge
Farnham
Köln
Paris
Sebastopol
Taipei
Tokyo
644992294.029.png 644992294.030.png 644992294.031.png 644992294.032.png 644992294.033.png 644992294.034.png 644992294.035.png 644992294.036.png
 
RESTful Web Services
by Leonard Richardson and Sam Ruby
Copyright © 2007 O’Reilly Media, Inc. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles ( http://safari.oreilly.com ). For more information, contact our corporate/
institutional sales department: (800) 998-9938 or corporate@oreilly.com .
Editor: Mike Loukides
Copy Editor: Peggy Wallace
Production Editor: Laurel R.T. Ruma
Proofreader: Laurel R.T. Ruma
Indexer: Joe Wizda
Cover Designer: Karen Montgomery
Interior Designer: David Futato
Illustrators: Robert Romano and Jessamyn Read
Printing History:
May 2007:
First Edition
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. The vulpine phalanger and related trade dress are trademarks of O’Reilly Media,
Inc.
Many of the designations uses by manufacturers and sellers to distinguish their products are claimed 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 caps.
While 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 of the information con-
tained herein.
TM
This book uses RepKover™, a durable and flexible lay-flat binding.
ISBN-10: 0-596-52926-0
ISBN-13: 978-0-596-52926-0
[M]
644992294.037.png 644992294.038.png 644992294.039.png 644992294.040.png 644992294.041.png 644992294.042.png 644992294.043.png 644992294.044.png
 
Table of Contents
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
1.
The Programmable Web and Its Inhabitants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Kinds of Things on the Programmable Web
4
HTTP: Documents in Envelopes
5
Method Information
8
Scoping Information
11
The Competing Architectures
13
Technologies on the Programmable Web
18
Leftover Terminology
20
2.
Writing Web Service Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Web Services Are Web Sites
23
del.icio.us: The Sample Application
26
Making the Request: HTTP Libraries
29
Processing the Response: XML Parsers
38
JSON Parsers: Handling Serialized Data
44
Clients Made Easy with WADL
47
3.
What Makes RESTful Services Different? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Introducing the Simple Storage Service
49
Object-Oriented Design of S3
50
Resources
52
HTTP Response Codes
54
An S3 Client
55
Request Signing and Access Control
64
Using the S3 Client Library
70
Clients Made Transparent with ActiveResource
71
Parting Words
77
vii
644992294.045.png 644992294.046.png 644992294.047.png 644992294.048.png 644992294.050.png 644992294.051.png 644992294.052.png
 
Zgłoś jeśli naruszono regulamin