[JAVA][Java Web Services - Up and Running, 2nd Edition].pdf

(10194 KB) Pobierz
www.it-ebooks.info
www.it-ebooks.info
SECOND EDITION
Java Web Services:
Up and Running
Martin Kalin
www.it-ebooks.info
Java Web Services: Up and Running, Second Edition
by Martin Kalin
Copyright © 2013 Martin Kalin. 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://my.safaribooksonline.com). For more information, contact our corporate/
institutional sales department: 800-998-9938 or
corporate@oreilly.com.
Editor:
Meghan Blanchette
Production Editor:
Rachel Steely
Copyeditor:
Rachel Leach
Proofreader:
BIM Indexing and Proofreading Services
September 2013:
Second Edition
Indexer:
Judith McConville
Cover Designer:
Randy Comer
Interior Designer:
David Futato
Illustrator:
Rebecca Demarest
Revision History for the Second Edition:
2013-08-23:
First release
See
http://oreilly.com/catalog/errata.csp?isbn=9781449365110
for release details.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly
Media, Inc.
Java Web Services: Up and Running,
Second Edition, the image of a great cormorant, and related
trade dress are trademarks of O’Reilly Media, Inc.
Many of the designations used 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 trade‐
mark 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 author assume no
responsibility for errors or omissions, or for damages resulting from the use of the information contained
herein.
ISBN: 978-1-449-36511-0
[LSI]
www.it-ebooks.info
Table of Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
1. Web Services Quickstart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Web Service Miscellany
What Good Are Web Services?
Web Services and Service-Oriented Architecture
A Very Short History of Web Services
From DCE/RPC to XML-RPC
Distributed Object Architecture: A Java Example
Web Services to the Rescue
What Is REST?
Verbs and Opaque Nouns
Review of HTTP Requests and Responses
HTTP as an API
Two HTTP Clients in Java
A First RESTful Example
How the Predictions Web Service Works
A Client Against the Predictions Web Service
Why Use Servlets for RESTful Web Services?
What’s Next?
3
4
7
8
9
11
12
13
17
18
20
21
24
25
33
34
37
40
41
52
53
54
55
56
2. RESTful Web Services: The Service Side. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
A RESTful Service as an HttpServlet
Implementation Details
Sample Client Calls Against the predictions2 Service
A RESTful Web Service as a JAX-RS Resource
A First JAX-RS Web Service Using Jersey
Publishing JAX-RS Resources with a Java Application
Publishing JAX-RS Resources with Tomcat
iii
www.it-ebooks.info
Zgłoś jeśli naruszono regulamin