Free Sample
+ Collection

RESTful Java Web Services

Jose Sandoval

Master core REST concepts and create RESTful web services in Java
RRP $23.99
RRP $39.99
Print + eBook

Want this title & more?

$12.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781847196460
Paperback256 pages

About This Book

  • 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

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.

Table of Contents

Chapter 1: RESTful Architectures
What is REST?
Uniform interfaces through HTTP requests
Web services and the big picture
Chapter 2: Accessing RESTful Services — Part 1
Getting the tools
RESTful clients
Chapter 3: Accessing RESTful Services — Part 2
Getting the tools
Semantic search mashup
Chapter 4: RESTful Web Services Design
Designing a RESTful web service
Chapter 5: Jersey: JAX-RS
Getting the tools
Jersey the JAX-RS 1.1 reference implementation
Web service architecture
Persistence layer
RESTful web service implementation with Jersey
Using this RESTful web service
Chapter 6: The Restlet Framework
Getting the tools
Restlet 1.1
Implementation using Restlet 1.1
Restlet 2.0
Implementation using Restlet 2.0
Chapter 7: RESTEasy: JAX-RS
Getting the tools
RESTEasy — a JAX-RS implementation
Web service architecture
RESTful web service implementation with RESTEasy
Chapter 8: Struts 2 and the REST Plugin
Getting the tools
Struts 2
Web service architecture
RESTful web service implementation with Struts 2
Chapter 9: Restlet Clients and Servers
Getting the tools
Restlet standalone applications
Chapter 10: Security and Performance

What You Will Learn

  • 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.


Read More