RESTful Java Web Services


RESTful Java Web Services
eBook: $23.99
Formats: PDF, PacktLib, ePub and Mobi formats
$20.40
save 15%!
Print + free eBook + free PacktLib access to the book: $63.98    Print cover: $39.99
$60.39
save 6%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Reviews
Support
Sample Chapters
  • Build powerful and flexible RESTful web services in Java using the most popular Java RESTful frameworks to date (Restlet, JAX-RS based frameworks Jersey and RESTEasy, and Struts 2)
  • Master the concepts to help you design and implement RESTful web services
  • Plenty of screenshots and clear explanations to facilitate learning
  • A developer's guide with practical examples to ensure proper understanding of all concepts and the differences between the frameworks studied

Book Details

Language : English
Paperback : 256 pages [ 235mm x 191mm ]
Release Date : November 2009
ISBN : 1847196462
ISBN 13 : 9781847196460
Author(s) : Jose Sandoval
Topics and Technologies : All Books, Web Development, BPEL, Java, Open Source, Web Services


Table of Contents

Preface
Chapter 1: RESTful Architectures
Chapter 2: Accessing RESTful Services — Part 1
Chapter 3: Accessing RESTful Services — Part 2
Chapter 4: RESTful Web Services Design
Chapter 5: Jersey: JAX-RS
Chapter 6: The Restlet Framework
Chapter 7: RESTEasy: JAX-RS
Chapter 8: Struts 2 and the REST Plugin
Chapter 9: Restlet Clients and Servers
Chapter 10: Security and Performance
Index
  • Chapter 1: RESTful Architectures
    • What is REST?
    • Resources
    • Representation
    • URI
    • Uniform interfaces through HTTP requests
      • GET/RETRIEVE
      • POST/CREATE
      • PUT/UPDATE
      • DELETE/DELETE
    • Web services and the big picture
    • Summary
  • Chapter 3: Accessing RESTful Services — Part 2
    • Getting the tools
    • Semantic search mashup
      • Application architecture
      • Web application definition
      • User interface layer
        • Parsing JSON structures
      • Servlet layer
        • SemanticHacker parser Servlet
        • Google search Servlet
        • Twitter search Servlet
        • Yahoo search Servlet
        • Yahoo image search Servlet
      • Compiling and running the application
    • Summary
  • Chapter 4: RESTful Web Services Design
    • Designing a RESTful web service
      • Requirements of sample web service
      • Resource identification
      • Representation definition
        • XML representations
        • JSON representations
      • URI definition
        • Executing logic with RESTful URIs
        • Using URIs to request representation types
    • Summary
  • Chapter 5: Jersey: JAX-RS
    • Getting the tools
    • JAX-RS
    • Jersey the JAX-RS 1.1 reference implementation
    • Annotations
      • Jersey resource
      • URIs
        • @Path
      • HTTP methods
        • @GET
        • @POST
        • @PUT
        • @DELETE
        • Relative paths in methods
      • URI variables
        • @PathParam
      • Input and output formats
        • @Consumes
        • @Produces
      • Parameters
        • @FormParam
    • Web service architecture
    • Persistence layer
    • RESTful web service implementation with Jersey
      • Application deployment
      • URI and resources
        • /users
        • /users/{username}
        • /messages
        • /messages/{messageID}
        • /messages/users/{username}
        • /messages/search/{search_item}
    • Using this RESTful web service
    • Summary
  • Chapter 6: The Restlet Framework
    • Getting the tools
    • Restlet
    • Restlet 1.1
      • Restlet application and URI mappings
      • Handling HTTP requests
        • HTTP GET and content negotiation (HTTP Accept header)
        • HTTP POST
        • HTTP PUT
        • HTTP DELETE
    • Implementation using Restlet 1.1
      • Restlet application and URI mappings
      • URIs and resources
        • /users
        • /users/{username}
        • /messages
        • /messages/{messageID}
        • /messages/users/{username}
        • /messages/search/{search_item}
    • Restlet 2.0
      • Restlet application and URI mappings
      • Annotations
        • @Get and content negotiation (HTTP Accept header)
        • @Post
        • @Put
        • @Delete
    • Implementation using Restlet 2.0
      • Restlet application and URI mappings
      • URIs and resources
        • /users
        • /users/{username}
        • /messages
        • /messages/{messageID}
        • /messages/users/{username}
        • /messages/search/{search_item}
    • Summary
  • Chapter 7: RESTEasy: JAX-RS
    • Getting the tools
    • RESTEasy — a JAX-RS implementation
    • Web service architecture
    • RESTful web service implementation with RESTEasy
      • Application deployment
      • URI and resources
        • /users
        • /users/{username}
        • /messages
        • /messages/{messageID}
        • /messages/users/{username}
        • /messages/search/{search_item}
    • Summary
  • Chapter 8: Struts 2 and the REST Plugin
    • Getting the tools
    • Struts 2
      • REST plugin
        • URI mappings
        • HTTP request handlers
    • Web service architecture
    • RESTful web service implementation with Struts 2
      • Application deployment
      • URIs and resources
        • /users and /users/{username}
        • /messages and /messages/{messageID}
        • /usermessages/{username}
        • /searchmessages/{search_item}
    • Summary
  • Chapter 9: Restlet Clients and Servers
    • Getting the tools
    • Restlet standalone applications
      • Restlet clients
        • HTTP GET requests
        • HTTP POST requests
        • HTTP PUT requests
        • HTTP DELETE requests
      • Restlet servers
    • Summary
  • Chapter 10: Security and Performance
    • Security
      • Securing web services
        • Custom token authentication
        • HTTP basic authentication
      • OAuth — accessing web services on behalf of users
    • Performance
      • High availability
      • Scalability
      • On-demand infrastructures
      • Performance recommendations
    • Summary

Jose Sandoval

Jose Sandoval is a software developer based in Canada. He's played and worked with web technologies since the Mosaic web browser was released into the wild, and for the last eight years he's consulted for various financial institutions and software companies in Canada and the US, concentrating in large-scale Java web applications. He holds a Bachelor of Mathematics degree from the University of Waterloo and an MBA from Wilfrid Laurier University.

Aside from coding and writing, he enjoys watching a good soccer match and coaching his son's soccer team. You can learn more about his interests at his personal web site http://www.josesandoval.com or his consulting firm's web site http://www.sandoval.ca.

Code Downloads

Download the code and support files for this book.


Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


Errata

- 19 submitted: last submission 08 Apr 2013

Errata type: Technical | Page number: 17

In the sequence diagram,under the section POST/CREATE,it is POST /students/Jane HTTP/1.1 and not PUT /students/Jane HTTP/1.1

 

Errata type: Technical | Page number: 17

In the sequence diagram, under the section POST/CREATE, the response code is 201(created) and not 200 (OK)

 

Errata type: Technical | Page number: 19

The sequence diagram,under the section PUT/UPDATE,shows POST /students/Jane HTTP/1.1 but PUT /students/Jane HTTP/1.1 is the correct one

 

Errata type: Typo | Page number: 81

Under the section "Getting the tools",the second line says 'D4bo' which is actually 'Db4o'

 

Errata type: Technical | Page number: 96

In the UsersResource, the given return statement of the createUser method is:
return UserBO.create(represen POST request creates a new user tation);

The correct statement is:
return UserBO.create(representation);

 

Errata type: Typo | Page number: 118

Typo on the first line of the HTTP DELETE section:
MessageResrouce
should be:
MessageResource.

 

Errata type: Typo | Page number: 128

In the code snippet template called {usename} is used, it should have been {username}.

 

Errata type: Typo | Page number: 132

Typo in the 4th last line of the note: "udpateRepresentation" should have been "updateRepresentation".

 

Errata type: Typo | Page number: 133

The note states: "om.noelios.restlet.ext.servlet_2.5.jar".It should have been "com.noelios.restlet.ext.servlet_2.5.jar".

 

Errata type: Typo | Page number: 149

Code snippet routes using template {usename} should have been {username} .

 

Errata type: Typo | Page number: 153

The note states "om.restlet.ext.servlet.jar".It should have been "org.restlet.ext.servlet.jar" .

 

Errata type: Typo | Page number: 156

Third last line in the "XML Representation" section: org.restlet.represntation.StringRepresentation should have been: org.restlet.representation.StringRepresentation .

 

Errata type: Typo | Page number: 160

In the last paragraph of the "XML Representation" section 'useraname' should be 'username' .

 

Errata type: Typo | Page number: 161

The last paragraph in the "HTTP PUT" section states 'org.restlet.represntation.Representation'.It should have been 'org.restlet.representation.Representation'.

 

Errata type: Graphics | Page number: 170

In the diagram: The Model Layer should not be used by the Resource Classes, but by the Business Layer .

 

Errata type: Typo | Page number: 194

In the third paragraph it states 'xml.sjp'.It should be 'xml.jsp'.

 

Errata type: Typo | Page number: 206

'org.restlet.representation.StringRepresenation' should have been 'org.restlet.representation.StringRepresentation'.

 

Errata type: Typo | Page number: 231

In the first paragraph the author of Scalable Internet Architectures is named Theo Schlssnagle.It is Schlossnagle and not Schlssnagle.

 

Errata type: Code | Page number: 152

The annotations for deleteUser() method is given as @Get("xml"), it should be @Delete.

 

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

RESTful Java Web Services +    Scratch 2.0 Beginner's Guide: Second Edition =
50% Off
the second eBook
Price for both: $37.50

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • REST architecture basics
  • What it means for a web service to be RESTful
  • How to connect to and consume RESTful web services such as Yahoo or Google
  • A RESTful web service design heuristic
  • How to deploy web services to Java web containers such as Tomcat and JBoss
  • How to implement an entire web service using the most popular open source frameworks currently available, including JAX-RS implementations Jersey and RESTEasy, Restlet, and Struts 2 with the REST plug-in
  • How to create standalone Java web services using the Restlet framework
  • How you can secure RESTful web services

In Detail

If you are already familiar with REST theory but are new to RESTful Java web services, and want to use the Java technology stack together with Java RESTful frameworks to create robust web services, this is the book for you.

This book is a guide to developing RESTful web services using Java and the most popular RESTful frameworks available today. It covers the theory of REST; practical coding examples for RESTful clients; a practical outline of the RESTful design process—yes, it's different from traditional web application development; and a complete implementation of a non-trivial web service using the following frameworks: Jersey's JAX-RS, Restlet's Lightweight REST, JBoss's JAX-RS RESTEasy, and Struts 2 with the REST plug-in.

We begin with an introduction to REST theory, for example, what it means for a web service to be RESTful, what it means for a web service to exchange representations of resources, and what it means to only use the conventional HTTP request method types—GET, POST, PUT, DELETE—for client/server communication. Before moving into the design and implementation process of a non-trivial web service, we look at a set of sample Java applications that connect to existing REST services that are freely available (Google, Yahoo, Twitter). We then outline a practical design process for RESTful web services and then cover the four most widely used frameworks available to date: JAX-RS implementations such as Jersey and RESTEasy, the Restlet framework, and Struts 2 with the REST plug-in. We cover each framework in detail to allow you to compare the strengths and weaknesses of each framework and to begin developing your own web services after the first reading; what's more, the whole source is included for you to modify and deploy in your own web services. Finally, we discuss the most common performance issues faced by RESTful web services and cover practical solutions to security-related issues such as authentication and data transfer.

A JAVA web developer's guide for building powerful and flexible RESTful web services

Approach

The approach we take is ideal for software developers with some, or extensive, programming experience: we design a RESTful API, which serves as our software specification, and implement it with every framework discussed in the book—there are no hypothetical examples; only practical working applications.

Who this book is for

This book is for Java developers who want to code RESTful web services using any of the open source RESTful frameworks available to date, for example, JAX-RS implementations such as Jersey and RESTEasy, the Restlet lightweight framework, or Struts 2 with the REST plug-in.

You don't need to know REST, as we cover the theory of REST and web services; however, you should be familiar with the Java language and have some understanding of Java web applications.

For each framework, we develop the same web service outlined in Chapter 4, so there is lots of working code available. This is a practical guide and the majority of the book is about coding RESTful web services, and not just about the theory of REST.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software