Java Web Services: Up and Running, 2nd Edition

Book description

Learn how to develop REST-style and SOAP-based web services and clients with this quick and thorough introduction. This hands-on book delivers a clear, pragmatic approach to web services by providing an architectural overview, complete working code examples, and short yet precise instructions for compiling, deploying, and executing them. You’ll learn how to write services from scratch and integrate existing services into your Java applications.

With greater emphasis on REST-style services, this second edition covers HttpServlet, Restlet, and JAX-RS APIs; jQuery clients against REST-style services; and JAX-WS for SOAP-based services. Code samples include an Apache Ant script that compiles, packages, and deploys web services.

  • Learn differences and similarities between REST-style and SOAP-based services
  • Program and deliver RESTful web services, using Java APIs and implementations
  • Explore RESTful web service clients written in Java, JavaScript, and Perl
  • Write SOAP-based web services with an emphasis on the application level
  • Examine the handler and transport levels in SOAP-based messaging
  • Learn wire-level security in HTTP(S), users/roles security, and WS-Security
  • Use a Java Application Server (JAS) as an alternative to a standalone web server

Publisher resources

View/Submit Errata

Table of contents

  1. Java Web Services: Up and Running
  2. Preface
    1. What’s Changed in the Second Edition?
    2. Web Service APIs and Publication Options
      1. The Publication Options
    3. Chapter-by-Chapter Overview
    4. Tools and IDEs
    5. Conventions Used in This Book
    6. Using Code Examples
    7. Safari® Books Online
    8. How to Contact Us
    9. Acknowledgments
  3. 1. Web Services Quickstart
    1. Web Service Miscellany
    2. What Good Are Web Services?
    3. Web Services and Service-Oriented Architecture
    4. A Very Short History of Web Services
      1. From DCE/RPC to XML-RPC
      2. Distributed Object Architecture: A Java Example
      3. Web Services to the Rescue
    5. What Is REST?
      1. Verbs and Opaque Nouns
    6. Review of HTTP Requests and Responses
    7. HTTP as an API
      1. Two HTTP Clients in Java
    8. A First RESTful Example
      1. How the Predictions Web Service Works
        1. The Tomcat web server
        2. An Ant script for service deployment
      2. A Client Against the Predictions Web Service
    9. Why Use Servlets for RESTful Web Services?
    10. What’s Next?
  4. 2. RESTful Web Services: The Service Side
    1. A RESTful Service as an HttpServlet
      1. Implementation Details
      2. Sample Client Calls Against the predictions2 Service
    2. A RESTful Web Service as a JAX-RS Resource
      1. A First JAX-RS Web Service Using Jersey
      2. Publishing JAX-RS Resources with a Java Application
      3. Publishing JAX-RS Resources with Tomcat
      4. The Adage Class
      5. JAX-RS Generation of XML and JSON Responses
      6. Porting the Predictions Web Service to JAX-RS
    3. A RESTful Web Service as Restlet Resources
      1. Sample Calls Against the adages2 Service
      2. Publishing the adages2 Restlet Service Without a Web Server
    4. A RESTful Service as a @WebServiceProvider
    5. What’s Next?
  5. 3. RESTful Web Services: The Client Side
    1. A Perl Client Against a Java RESTful Web Service
    2. A Client Against the Amazon E-Commerce Service
    3. A Standalone JAX-B Example
      1. The XStream Option
    4. Another Client Against the Amazon E-Commerce Service
    5. The CTA Bus-Tracker Services
    6. RESTful Clients and WADL Documents
    7. The JAX-RS Client API
    8. JSON for JavaScript Clients
      1. JSONP and Web Services
      2. A Composed RESTful Service with jQuery
      3. An Ajax Polling Example
    9. What’s Next?
  6. 4. SOAP-Based Web Services
    1. A SOAP-Based Web Service
    2. The RandService in Two Files
    3. Clients Against the RandService
      1. A Java Client Against the RandService
      2. A C# Client Against the RandService
      3. A Perl Client Against the RandService
    4. The WSDL Service Contract in Detail
      1. The types Section
      2. The message Section
      3. The portType Section
      4. The binding Section
      5. The service Section
      6. Java and XML Schema Data Type Bindings
      7. Wrapped and Unwrapped Document Style
      8. wsimport Artifacts for the Service Side
    5. SOAP-Based Clients Against Amazon’s E-Commerce Service
      1. Asynchronous Clients Against SOAP-Based Services
    6. What’s Next?
  7. 5. SOAP Handlers and Faults
    1. The Handler Level in SOAP-Based Services and Clients
    2. Handlers and Faults in the predictionsSOAP Service
      1. The Backend Support Classes
      2. From the Client to the Service
      3. Signature Verification
      4. Faults from the Application and Handler Levels
      5. Linking the Service-Side Handler to the Service
    3. A Handler Chain with Two Handlers
    4. SOAP-Based Web Services and Binary Data
    5. The Transport Level
    6. Axis2
    7. What’s Next?
  8. 6. Web Services Security
    1. Wire-Level Security
      1. HTTPS Basics
      2. Symmetric and Asymmetric Encryption/Decryption
      3. How HTTPS Provides the Three Security Services
      4. The HTTPS Handshake
      5. The HttpsURLConnection Class
    2. A Very Lightweight HTTPS Server and Client
    3. HTTPS in a Production-Grade Web Server
      1. Enforcing HTTPS Access to a Web Service
      2. An HTTPS Client Against the predictions2 Service
    4. Container-Managed Security
      1. Linking the Service web.xml with a Tomcat Security Realm
      2. The Client Side in Users/Roles Security
      3. Using the curl Utility for HTTPS Testing
      4. A @WebService Under HTTPS with Users/Roles Security
      5. Using a Digested Password Instead of a Password
    5. WS-Security
      1. Securing a @WebService with WS-Security
    6. What’s Next?
  9. 7. Web Services and Java Application Servers
    1. The Web Container
      1. The Message-Oriented Middleware
      2. The Enterprise Java Bean Container
      3. The Naming and Lookup Service
      4. The Security Provider
      5. The Client Container
      6. The Database System
    2. Toward a Lightweight JAS
    3. GlassFish Basics
    4. Servlet-Based Web Services Under GlassFish
      1. An Example with Mixed APIs
    5. An Interactive Website and a SOAP-Based Web Service
    6. A @WebService as a @Stateless Session EJB
      1. Packaging and Deploying the predictionsEJB Service
      2. A Client Against the predictionsEJB Service
    7. TomEE: Tomcat with Java EE Extensions
      1. Porting the predictionsEJB Web Service to TomEE
      2. Deploying an EJB in a WAR File
    8. Where Is the Best Place to Be in Java Web Services?
      1. Back to the Question at Hand
  10. Index
  11. About the Author
  12. Colophon
  13. Copyright

Product information

  • Title: Java Web Services: Up and Running, 2nd Edition
  • Author(s): Martin Kalin
  • Release date: August 2013
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781449373870