You are previewing SOA Using Java™ Web Services.
O'Reilly logo
SOA Using Java™ Web Services

Book Description

Expert Solutions and State-of-the-Art Code Examples

SOA Using Java™ Web Services is a hands-on guide to implementing Web services and Service Oriented Architecture (SOA) with today’s Java EE 5 and Java SE 6 platforms. Author Mark Hansen presents in explicit detail the information that enterprise developers and architects need to succeed, from best-practice design techniques to state-of-the-art code samples.

Hansen covers creating, deploying, and invoking Web services that can be composed into loosely coupled SOA applications. He begins by reviewing the “big picture,” including the challenges of Java-based SOA development and the limitations of traditional approaches. Next, he systematically introduces the latest Java Web Services (JWS) APIs and walks through creating Web services that integrate into a comprehensive SOA solution. Finally, he shows how application frameworks based on JWS can streamline the entire SOA development process and introduces one such framework: SOA-J.

The book

  • Introduces practical techniques for managing the complexity of Web services and SOA, including best-practice design examples

  • Offers hard-won insights into building effective SOA applications with Java Web Services

  • Illuminates recent major JWS improvements–including two full chapters on JAX-WS 2.0

  • Thoroughly explains SOA integration using WSDL, SOAP, Java/XML mapping, and JAXB 2.0 data binding

  • Walks step by step through packaging and deploying Web services components on Java EE 5 with JSR-181 (WS-Metadata 2.0) and JSR-109

  • Includes specific code solutions for many development issues, from publishing REST endpoints to consuming SOAP services with WSDL

  • Presents a complete case study using the JWS APIs, together with an Ajax front end, to build a SOA application integrating Amazon, Yahoo Shopping, and eBay

  • Contains hundreds of code samples–all tested with the GlassFish Java EE 5 reference implementation–that are downloadable from the companion Web site, http://soabook.com.



  • Foreword
    Preface

     Acknowledgments
    About the Author

    Chapter 1: Service-Oriented Architecture with Java Web Services
    Chapter 2: An Overview of Java Web Services
    Chapter 3: Basic SOA Using REST
    Chapter 4: The Role of WSDL, SOAP, and Java/XML Mapping in SOA
    Chapter 5: The JAXB 2.0 Data Binding
    Chapter 6: JAX-WS–Client-Side Development
    Chapter 7: JAX-WS 2.0–Server-Side Development
    Chapter 8: Packaging and Deployment of SOA Components (JSR-181 and JSR-109)
    Chapter 9: SOAShopper: Integrating eBay, Amazon, and Yahoo! Shopping
    Chapter 10: Ajax and Java Web Services
    Chapter 11: WSDL-Centric Java Web Services with SOA-J
    Appendix A: Java, XML, and Web Services Standards Used in This Book
    Appendix B: Software Configuration Guide
    Appendix C: Namespace
    Prefixes
    Glossary

    References

    Index

    Table of Contents

    1. SOA Using Java™ Web Services
      1. Foreword
      2. Preface
        1. About This Book
          1. An Unbiased Guide to Java Web Services for SOA
          2. Written for Java Developers and Architects
          3. Knowledge of J2SE 5.0 Is Assumed
          4. Why GlassFish?
          5. Why Some Topics Aren’t Covered
            1. SOA Design Principles
            2. UDDI
            3. Enterprise Messaging
            4. WS-Addressing, WS-Security, and the Many Other WS-* Standards
          6. Fonts and Special Characters
          7. Code Fragments in Text
      3. Acknowledgments
      4. About the Author
      5. 1. Service-Oriented Architecture with Java Web Services
          1. 1.1. Am I Stupid, or Is Java Web Services Really Hard?
            1. 1.1.1. Don’t Drink That Kool-Aid
            2. 1.1.2. JWS Is a Toolset, Not an Application Framework
            3. 1.1.3. Epiphany
          2. 1.2. Web Services Platform Architecture
            1. 1.2.1. Invocation
            2. 1.2.2. Serialization
            3. 1.2.3. Deployment
          3. 1.3. Java Web Services Standards: Chapters 2 through 8
          4. 1.4. The SOAShopper Case Study: Chapters 9 and 10
          5. 1.5. SOA-J and WSDL-Centric Development: Chapter 11
      6. 2. An Overview of Java Web Services
          1. 2.1. The Role of JWS in SOA Application Development
            1. 2.1.1. A Hypothetical SOA Application
            2. 2.1.2. JWS Enables SOA Development
          2. 2.2. A Quick Overview of the Ease-of-Use Features
            1. 2.2.1. Source Code Annotations
            2. 2.2.2. Standard WSDL/Java Mapping
            3. 2.2.3. Standard Serialization Context
            4. 2.2.4. Development Models
            5. 2.2.5. JWS Trade-Offs
          3. 2.3. JAX-WS 2.0
            1. 2.3.1. Java/WSDL Mapping
            2. 2.3.2. Static WSDL
            3. 2.3.3. Dynamic and Static Clients
            4. 2.3.4. Invocation with Java Interface Proxies
            5. 2.3.5. Invocation with XML
            6. 2.3.6. XML Service Providers
            7. 2.3.7. Handler Framework
            8. 2.3.8. Message Context
            9. 2.3.9. SOAP Binding
            10. 2.3.10. HTTP Binding
            11. 2.3.11. Converting Exceptions to SOAP Faults
            12. 2.3.12. Asynchronous Invocation
            13. 2.3.13. One-Way Operations
            14. 2.3.14. Client-Side Thread Management
            15. 2.3.15. WSDL Styles—Support for RPC/Literal and Document/Literal Wrapped
            16. 2.3.16. XML Catalogs
            17. 2.3.17. Pseudoreference Passing (Holder<T> for Out and In/Out Parameters)
            18. 2.3.18. Run-time Endpoint Publishing (Java SE Only)
          4. 2.4. JAXB 2.0
            1. 2.4.1. Binding XML Schema to Java Representations
            2. 2.4.2. Mapping Java Types to XML Schema
            3. 2.4.3. Mapping Annotations
            4. 2.4.4. Binding Language
            5. 2.4.5. Binding Run-time Framework (Marshal/Unmarshal)
            6. 2.4.6. Validation
            7. 2.4.7. Portability
            8. 2.4.8. Marshal Event Callbacks
            9. 2.4.9. Partial Binding
            10. 2.4.10. Binary Data Encoding (MTOM or WS-I)
          5. 2.5. WS-Metadata 2.0
            1. 2.5.1. WSDL Mapping Annotations
            2. 2.5.2. SOAP Binding Annotations
            3. 2.5.3. Handler Annotations
            4. 2.5.4. Service Implementation Bean
            5. 2.5.5. Start from WSDL and Java
            6. 2.5.6. Automatic Deployment
          6. 2.6. WSEE 1.2
            1. 2.6.1. Port Component
            2. 2.6.2. Servlet Endpoints
            3. 2.6.3. EJB Endpoints
            4. 2.6.4. Simplified Packaging
            5. 2.6.5. Handler Programming Model
          7. 2.7. Impact of Other Java EE 5 Annotation Capabilities
            1. 2.7.1. Dependency Injection
            2. 2.7.2. Interceptors
            3. 2.7.3. POJO Support in EJB 3.0
          1. 2.8. Conclusions
            1. 2.8.1. Configuring Your Environment to Build and Run the Software Examples
      7. 3. Basic SOA Using REST
          1. 3.1. Why REST?
            1. 3.1.1. What Is REST?
            2. 3.1.2. Topics Covered in This Chapter
          2. 3.2. XML Documents and Schema for EIS Records
            1. 3.2.1. No WSDL Doesn’t Necessarily Mean No Interfaces
          3. 3.3. REST Clients with and without JWS
            1. 3.3.1. Getting EIS Records from a REST Service without Using JWS
            2. 3.3.2. Getting EIS Records from a REST Service with JWS
            3. 3.3.3. Sending EIS Records to a REST Service without Using JWS
            4. 3.3.4. Sending EIS Records to a REST Service with JWS
          4. 3.4. SOA-Style Integration Using XSLT and JAXP for Data Transformation
            1. 3.4.1. How and Why to Use XSLT for Data Transformation
            2. 3.4.2. XSLT Processing Using JAXP
          5. 3.5. RESTful Services with and without JWS
            1. 3.5.1. Deploying a REST Service without Using JWS
            2. 3.5.2. Deploying a RESTful Service with JWS
          1. 3.6. Conclusions
      8. 4. The Role of WSDL, SOAP, and Java/XML Mapping in SOA
          1. 4.1. The Role of WSDL in SOA
            1. 4.1.1. A WSDL Example
          2. 4.2. The Role of SOAP in SOA
          3. 4.3. Dispatching: How JAX-WS 2.0 Maps WSDL/SOAP to Java Invocation
            1. 4.3.1. Determining the WSDL Port
            2. 4.3.2. The Role of the WS-I Basic Profile
            3. 4.3.3. RPC/Literal
            4. 4.3.4. Document/Literal
            5. 4.3.5. Document/Literal Wrapped
            6. 4.3.6. Summary of the Dispatching Process
            7. 4.3.7. Shortcomings of the JAX-WS 2.0 Dispatching for SOA Integration
          4. 4.4. Working around Some JAX-WS 2.0 Dispatching Limitations
          5. 4.5. SOA Often Requires “Start from WSDL and Java”
            1. 4.5.1. The Role of Java/XML Mapping in SOA
            2. 4.5.2. Limitations of JAXB 2.0 for Java/XML Mapping in SOA
          6. 4.6. Working around JAXB 2.0 Java/XML Mapping Limitations
            1. 4.6.1. Using the Schema Compiler and Java
            2. 4.6.2. Using the Schema Generator and XSLT
          1. 4.7. Conclusions
      9. 5. The JAXB 2.0 Data Binding
          1. 5.1. Binding versus Mapping
          2. 5.2. An Overview of the Standard JAXB 2.0 Java/XML Binding
          3. 5.3. Implementing Type Mappings with JAXB 2.0
          4. 5.4. A Recursive Framework for Type Mappings
          5. 5.5. Implementing Type Mappings with JAXB 2.0 Annotations
          6. 5.6. Implementing Type Mappings with the JAXB 2.0 Binding Language
          7. 5.7. Implementing Type Mappings with the JAXB 2.0 XmlAdapter Class
          8. 5.8. JAXB 2.0 for Data Transformation (Instead of XSLT)
          1. 5.9. Conclusions
      10. 6. JAX-WS—Client-Side Development
          1. 6.1. JAX-WS Proxies
            1. 6.1.1. The JAX-WS WSDL to Java Mapping
            2. 6.1.2. Service Endpoint Interface Annotations
            3. 6.1.3. Invoking a Web Service with a Proxy
            4. 6.1.4. Fault Handling with Proxies
          2. 6.2. XML Messaging
            1. 6.2.1. XML Messaging with Raw XML
            2. 6.2.2. XML Messaging with Custom Annotated JAXB Classes
          3. 6.3. Invocation with Custom Java/XML Mappings: An Example Using Castor Instead of JAXB
          4. 6.4. Asynchronous Invocation
            1. 6.4.1. Polling
            2. 6.4.2. Asynchronous Methods with Proxies
            3. 6.4.3. Callback
          5. 6.5. SOAP Message Handlers
          1. 6.6. Conclusions
      11. 7. JAX-WS 2.0—Server-Side Development
          1. 7.1. JAX-WS Server-Side Architecture
          2. 7.2. Start from WSDL Using a Service Endpoint Interface (SEI)
          3. 7.3. Providers and XML Processing without JAXB
          4. 7.4. Deploying Web Services Using Custom Java/XML Mappings
          5. 7.5. Validation and Fault Processing
            1. 7.5.1. Validation
            2. 7.5.2. Fault Processing
          6. 7.6. Server-Side Handlers
          7. 7.7. Java SE Deployment with javax.xml.ws.Endpoint
          1. 7.8. Conclusions
      12. 8. Packaging and Deployment of SOA Components (JSR-181 and JSR-109)
          1. 8.1. Web Services Packaging and Deployment Overview
            1. 8.1.1. Packaging a Servlet Endpoint Using a WAR
            2. 8.1.2. Packaging an EJB Endpoint Using an EJB-JAR
            3. 8.1.3. Auto-Deployment
            4. 8.1.4. Overview of the Container’s Deployment Processing
            5. 8.1.5. EJB Endpoint Deployment and Dispatching
          2. 8.2. Deployment without Deployment Descriptors
            1. 8.2.1. Using Only a Service Implementation Bean
            2. 8.2.2. Using a Service Endpoint Interface
            3. 8.2.3. Including a WSDL Artifact
          3. 8.3. Using Deployment Descriptors
            1. 8.3.1. web.xml for Servlet Endpoints
            2. 8.3.2. ejb-jar.xml for Stateless Session Bean Endpoints
            3. 8.3.3. When to Use webservices.xml
            4. 8.3.4. Platform-Specific Deployment Descriptors
          4. 8.4. Automatic Deployment with GlassFish
          5. 8.5. Web Services Security
          6. 8.6. OASIS XML Catalogs 1.1
          7. 8.7. Wrapping Up
      13. 9. SOAShopper: Integrating eBay, Amazon, and Yahoo! Shopping
          1. 9.1. Overview of SOAShopper
          2. 9.2. SOAShopper SOAP Services
          3. 9.3. An SOAShopper RESTful Service and the Standard XML Schema
          4. 9.4. Service Implementation
          5. 9.5. eBay and Amazon Services (SOAP)
          6. 9.6. Yahoo! Services (REST)
          7. 9.7. SOAShopper API and the Integration Layer
          8. 9.8. Conclusions about Implementing Real-World SOA Applications with Java EE
      14. 10. Ajax and Java Web Services
          1. 10.1. Quick Overview of Ajax
          2. 10.2. Ajax Together with Java EE Web Services
          3. 10.3. Sample Code: An Ajax Front-End for SOAShopper
          4. 10.4. Conclusions about Ajax and Java EE
      15. 11. WSDL-Centric Java Web Services with SOA-J
          1. 11.1. SOA-J Architecture
          2. 11.2. WSDL-Centric Development with SOA-J
          3. 11.3. Invocation Subsystem
          4. 11.4. Serialization Subsystem
          5. 11.5. Deployment Subsystem
          1. 11.6. Conclusions
      16. A. Java, XML, and Web Services Standards Used in This Book
        1. Web Services Description Language (WSDL) 1.1
        2. SOAP Version 1.1
        3. XSL Transformations (XSLT) Version 1.0
        4. XML Schema Version 1.0
        5. JAX-WS 2.0 and JAXB 2.0
      17. B. Software Configuration Guide
          1. B.1. Install Java EE 5 SDK
          2. B.2. Install Apache Ant 1.7.x
          3. B.3. Install Apache Maven 2.0.x
          4. B.4. Install the Book Example Code
          5. B.5. Configure Maven
          6. B.6. Configure Ant
          7. B.7. Starting and Stopping the GlassFish Server
          8. B.8. Test the Installation by Running an Example
          9. B.9. Build and Deploy the SOAShopper Case Study (Chapters 9 and 10)
          10. B.10. Build and Deploy the SOA-J Application Framework (Chapter 11)
          11. B.11. Install Java SE 6 (Optional)
      18. C. Namespace Prefixes
      19. Glossary
      20. References