You are previewing Java Web Services: Up and Running.
O'Reilly logo
Java Web Services: Up and Running

Book Description

This example-driven book offers a thorough introduction to Java's APIs for XML Web Services (JAX-WS) and RESTful Web Services (JAX-RS). Java Web Services: Up and Running takes a clear, pragmatic approach to these technologies by providing a mix of architectural overview, complete working code examples, and short yet precise instructions for compiling, deploying, and executing an application. You'll learn how to write web services from scratch and integrate existing services into your Java applications. With Java Web Services: Up and Running, you will:

  • Understand the distinction between SOAP-based and REST-style services

  • Write, deploy, and consume SOAP-based services in core Java

  • Understand the Web Service Definition Language (WSDL) service contract

  • Recognize the structure of a SOAP message

  • Learn how to deliver Java-based RESTful web services and consume commercial RESTful services

  • Know security requirements for SOAP- and REST-based web services

  • Learn how to implement JAX-WS in various application servers

Ideal for students as well as experienced programmers, Java Web Services: Up and Running is the concise guide you need to start working with these technologies right away.

Table of Contents

  1. Java Web Services: Up and Running
    1. SPECIAL OFFER: Upgrade this ebook with O’Reilly
    2. A Note Regarding Supplemental Files
    3. Preface
      1. Code-Driven Approach
      2. Chapter-by-Chapter Overview
      3. Freedom of Choice: The Tools/IDE Issue
      4. Conventions Used in This Book
      5. Using Code Examples
      6. Safari® Books Online
      7. How to Contact Us
      8. Acknowledgments
    4. 1. Java Web Services Quickstart
      1. What Are Web Services?
        1. What Good Are Web Services?
      2. A First Example
        1. The Service Endpoint Interface and Service Implementation Bean
        2. A Java Application to Publish the Web Service
        3. Testing the Web Service with a Browser
      3. A Perl and a Ruby Requester of the Web Service
      4. The Hidden SOAP
      5. A Java Requester of the Web Service
      6. Wire-Level Tracking of HTTP and SOAP Messages
      7. What’s Clear So Far?
        1. Key Features of the First Code Example
      8. Java’s SOAP API
      9. An Example with Richer Data Types
        1. Publishing the Service and Writing a Client
      10. Multithreading the Endpoint Publisher
      11. What’s Next?
    5. 2. All About WSDLs
      1. What Good Is a WSDL?
        1. Generating Client-Support Code from a WSDL
        2. The @WebResult Annotation
      2. WSDL Structure
        1. A Closer Look at WSDL Bindings
        2. Key Features of Document-Style Services
        3. Validating a SOAP Message Against a WSDL’s XML Schema
        4. The Wrapped and Unwrapped Document Styles
      3. Amazon’s E-Commerce Web Service
        1. An E-Commerce Client in Wrapped Style
        2. An E-Commerce Client in Unwrapped Style
        3. Tradeoffs Between the RPC and Document Styles
        4. An Asynchronous E-Commerce Client
      4. The wsgen Utility and JAX-B Artifacts
        1. A JAX-B Example
        2. Marshaling and wsgen Artifacts
        3. An Overview of Java Types and XML Schema Types
        4. Generating a WSDL with the wsgen Utility
      5. WSDL Wrap-Up
        1. Code First Versus Contract First
        2. A Contract-First Example with wsimport
        3. A Code-First, Contract-Aware Approach
        4. Limitations of the WSDL
      6. What’s Next?
    6. 3. SOAP Handling
      1. SOAP: Hidden or Not?
        1. SOAP 1.1 and SOAP 1.2
        2. SOAP Messaging Architecture
        3. Programming in the JWS Handler Framework
        4. The RabbitCounter Example
        5. Injecting a Header Block into a SOAP Header
        6. Configuring the Client-Side SOAP Handler
        7. Adding a Handler Programmatically on the Client Side
        8. Generating a Fault from a @WebMethod
        9. Adding a Logical Handler for Client Robustness
        10. Adding a Service-Side SOAP Handler
        11. Summary of the Handler Methods
      2. The RabbitCounter As a SOAP 1.2 Service
      3. The MessageContext and Transport Headers
        1. An Example to Illustrate Transport-Level Access
      4. Web Services and Binary Data
        1. Three Options for SOAP Attachments
        2. Using Base64 Encoding for Binary Data
        3. Using MTOM for Binary Data
      5. What’s Next?
    7. 4. RESTful Web Services
      1. What Is REST?
        1. Verbs and Opaque Nouns
      2. From @WebService to @WebServiceProvider
      3. A RESTful Version of the Teams Service
        1. The WebServiceProvider Annotation
        2. Language Transparency and RESTful Services
        3. Summary of the RESTful Features
        4. Implementing the Remaining CRUD Operations
        5. Java API for XML Processing
      4. The Provider and Dispatch Twins
        1. A Provider/Dispatch Example
        2. More on the Dispatch Interface
        3. A Dispatch Client Against a SOAP-based Service
      5. Implementing RESTful Web Services As HttpServlets
        1. The RabbitCounterServlet
        2. Requests for MIME-Typed Responses
      6. Java Clients Against Real-World RESTful Services
        1. The Yahoo! News Service
        2. The Amazon E-Commerce Service: REST Style
        3. The RESTful Tumblr Service
      7. WADLing with Java-Based RESTful Services
      8. JAX-RS: WADLing Through Jersey
      9. The Restlet Framework
      10. What’s Next?
    8. 5. Web Services Security
      1. Overview of Web Services Security
      2. Wire-Level Security
        1. HTTPS Basics
        2. Symmetric and Asymmetric Encryption/Decryption
        3. How HTTPS Provides the Three Security Services
        4. The HttpsURLConnection Class
      3. Securing the RabbitCounter Service
        1. Adding User Authentication
        2. HTTP BASIC Authentication
      4. Container-Managed Security for Web Services
        1. Deploying a @WebService Under Tomcat
        2. Securing the @WebService Under Tomcat
        3. Application-Managed Authentication
        4. Container-Managed Authentication and Authorization
        5. Configuring Container-Managed Security Under Tomcat
        6. Using a Digested Password Instead of a Password
        7. A Secured @WebServiceProvider
      5. WS-Security
        1. Securing a @WebService with WS-Security Under Endpoint
        2. The Prompter and the Verifier
        3. The Secured SOAP Envelope
        4. Summary of the WS-Security Example
      6. What’s Next?
    9. 6. JAX-WS in Java Application Servers
      1. Overview of a Java Application Server
      2. Deploying @WebServices and @WebServiceProviders
        1. Deploying @WebServiceProviders
      3. Integrating an Interactive Website and a Web Service
      4. A @WebService As an EJB
        1. Implementation As a Stateless Session EJB
        2. The Endpoint URL for an EBJ-Based Service
        3. Database Support Through an @Entity
        4. The Persistence Configuration File
        5. The EJB Deployment Descriptor
        6. Servlet and EJB Implementations of Web Services
      5. Java Web Services and Java Message Service
      6. WS-Security Under GlassFish
        1. Mutual Challenge with Digital Certificates
        2. MCS Under HTTPS
        3. MCS Under WSIT
        4. The Dramatic SOAP Envelopes
      7. Benefits of JAS Deployment
      8. What’s Next?
    10. 7. Beyond the Flame Wars
      1. A Very Short History of Web Services
        1. The Service Contract in DCE/RPC
        2. XML-RPC
        3. Standardized SOAP
      2. SOAP-Based Web Services Versus Distributed Objects
      3. SOAP and REST in Harmony
    11. Index
    12. About the Author
    13. Colophon
    14. SPECIAL OFFER: Upgrade this ebook with O’Reilly