You are previewing RESTful Web Services with Dropwizard.
O'Reilly logo
RESTful Web Services with Dropwizard

Book Description

The world is moving towards RESTful Web Services and now you can get up to speed quickly and painlessly. This tutorial covers all you need to create your own Web Service applications using the Dropwizard libraries.

In Detail

The RESTful Web Services concept is constantly growing compared to SOAP technologies. Used by many API providers, RESTful has started to become the architecture of choice for the enterprise SOA as well. Dropwizard combines everything needed to create production ready RESTful Web Services, combining the most powerful, stable and well-known RESTful Java-based libraries.

This practical guide will help you learn how to create, configure, and implement a dynamic Web Service application by showcasing practical examples using the most important modules of Dropwizard and combining them together.

Starting from using Maven to create an empty default Java application to deploying a production-ready scalable Web Service application, this book demonstrates the capabilities of Dropwizard and the advantages of using it.

Discover how to use Jersey to create rest resources, and add them to Dropwizard's bootstrapped environment so they can be served by its embedded Jetty server. Learn how to combine and utilize the Database. Understand more about Configuration, Testing and Monitoring libraries to create a Web Service application in a step-by-step manner using solid examples. Also gain insight on how to secure your Web Services and validate incoming requests with minimum effort.

This book is an invaluable asset to anyone who wants to create a RESTful Web Service application with the combined libraries of Dropwizard.

What You Will Learn

  • Build a sample Web Service application powered by Jersey
  • Configure your application and externalize your configuration settings
  • Use jDBI to interact with databases
  • Validate Web Service requests
  • Build Web Service clients
  • Add runtime health checks to ensure your application's optimal performance
  • Ensure your application's stability by creating unit tests using the Dropwizard testing modules
  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Table of Contents

    1. RESTful Web Services with Dropwizard
      1. Table of Contents
      2. RESTful Web Services with Dropwizard
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers and more
          1. Why Subscribe?
          2. Free Access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Getting Started with Dropwizard
        1. Web service development with Dropwizard
        2. Preparing your development environment
          1. Getting ready
          2. How to do it…
            1. Downloading and installing Java
            2. Downloading and installing Maven
            3. Downloading and installing MySQL
          3. How it works…
      9. 2. Creating a Dropwizard Application
        1. Generating a Maven-based project
          1. Getting ready
          2. How to do it…
          3. How it works…
        2. Configuring Dropwizard dependencies and building the configuration
          1. How to do it…
          2. How it works…
            1. The exclusion of digital signatures
        3. Hello World using Dropwizard
          1. How to do it…
          2. How it works…
          3. There's more…
            1. Logging
            2. Default HTTP Ports
      10. 3. Configuring the Application
        1. Externalizing the application's configuration
          1. How to do it…
          2. How it works…
          3. There's more…
            1. Dropwizard's configuration parameters
            2. YAML
        2. Validating configuration settings
          1. How to do it…
          2. How it works…
          3. There's more…
            1. Specifying default parameters
      11. 4. Creating and Adding REST Resources
        1. Creating a resource class
          1. How to do it...
          2. How it works…
          3. There's more…
            1. HTTP verbs – RESTful convention
            2. HTTP response codes
            3. The Response class
      12. 5. Representations – RESTful Entities
        1. Creating a representation class
          1. How to do it…
          2. How it works…
          3. There's more…
            1. The Jackson Java JSON processor
            2. JSON arrays
            3. Ignoring properties
        2. Serving representations through the Resource class
          1. How to do it…
          2. How it works…
          3. There's more...
            1. Using cURL to perform HTTP requests
        3. Mapping the request data to representations
          1. How to do it…
          2. How it works…
      13. 6. Using a Database
        1. Preparing the database
          1. Getting ready
          2. How to do it…
          3. How it works…
        2. Interacting with the database
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. The JDBI fluent style API
            2. The @MapResultAsBean annotation
      14. 7. Validating Web Service Requests
        1. Adding validation constraints
          1. How to do it…
          2. How it works…
          3. There's more…
            1. List of constraint annotations
        2. Performing validation
          1. How to do it…
          2. How it works…
          3. There's more…
            1. The @Valid annotation
        3. Cross-field validation
          1. How to do it…
          2. How it works…
      15. 8. The Web Service Client
        1. Building a client for our application
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        2. Interacting with our services
          1. How to do it…
          2. How it works…
          3. There's more…
      16. 9. Authentication
        1. Building a basic HTTP authenticator
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Setting client's credentials
            2. Optional authentication
            3. Authentication schemes
        2. Authenticating users with credentials stored in a database
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Caching
      17. 10. The User Interface – Views
        1. Building a user interface for the web service client
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Serving static assets
      18. A. Testing a Dropwizard Application
        1. Creating a complete test for the application
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        2. Adding health checks
          1. How to do it…
          2. How it works…
      19. B. Deploying a Dropwizard Application
        1. Preparing the application for deployment
          1. How to do it…
          2. How it works…
          3. There's more…
            1. Multiple configuration files
      20. Index