You are previewing Spring Web Services 2 Cookbook.
O'Reilly logo
Spring Web Services 2 Cookbook

Book Description

In this book you’ll discover over sixty recipes, giving you a first-hand understanding of how to implement Spring Web Services 2. Ideal as both a newcomer’s learning tool and an expert’s reference manual.

  • Create contract-first Web services

  • Explore different frameworks of Object/XML mapping

  • Secure Web Services by Authentication, Encryption/Decryption and Digital Signature

  • Learn contract-last Web Services using Spring Remoting and Apache CXF

  • Implement automated functional and load testing

  • Develop RESTful Web-Services

  • Log and trace SOAP messages

  • In Detail

    Spring Web Services is a product of the Spring community focused on creating document-driven Web services.

    Spring Web Services aims to facilitate contract-first SOAP service development, allowing for the creation of flexible web services using one of the many ways to manipulate XML payloads.

    This comprehensive guide -- which provides professional expertise on a variety of technical topics right from setting-up a contract-first Web-Service, creating client of a Web-Service to serialization, monitoring, testing and security using Spring-WS -- helps you enhance your skills in Spring Web Services.

    Spring Web Services 2 Cookbook includes a wide variety of recipes that covers most important topics used in real-world applications. It is a well-rounded guide covering a lot of ground in the Spring Web Services domain using systematic arranged chapters and focused recipes.

    The book begins with setting up a contract first Web Service over various protocols such as JMS, XMPP, and Email. The next chapter targets creating clients for SOAP Web Services. We then learn how to test and monitor the Web Service using tools like soapUI and TCPMon. Building on, logging, tracing and exception handling are detailed in the subsequent chapter. The book then covers marshalling and unmarshalling using different technologies like JAXB2, XMLBeans, JibX, XStream, MooseXML etc. Securing WebServices through authentication, authorization, encryption and decryption and digital signature using Spring-WS features based on XWSS and WSS4J Libraries is outlined in the next chapter two chapters. The book then tackles development of RESTful Web Services. Finally, Setting up Web Services using Spring Remoting based on various technologies like HTTP , RMI, JMS, JAXWS and a Web Service using Apache CXF on JAX-WS front-end are explained.

    This book will help relatively new developers in accelerating their learning process and experienced developers in expanding their skills sets of Spring Web Services.

    Table of Contents

    1. Copyright
    2. Credits
    3. About the Authors
    4. About the Reviewers
    5. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    6. 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
    7. 1. Building SOAP Web-Services
      1. Introduction
      2. Using Maven for building and running a Spring-WS project
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Creating a data contract
        1. Getting ready
        2. How to do it...
          1. How it works...
      4. Setting up a Web-Service using DispatcherServlet
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Simplifying the creation of a Web-Service using MessageDispatcherServlet
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      6. Setting up a Web-Service on JMS transport
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Setting up a Web-Service on E-mail transport
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Setting up a Web-Service on embedded HTTP transport
        1. Getting ready
        2. How to do it...
        3. How it works...
      9. Setting up Spring-WS on XMPP transport
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      10. Setting up a contract-first Web-Service
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      11. Setting up a simple endpoint mapping for the Web-Service
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      12. Setting up an endpoint by annotating the payload-root
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      13. Setting up a transport-neutral WS-Addressing endpoint
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      14. Setting up an endpoint using an XPath expression
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      15. Handling the incoming XML messages using DOM
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      16. Handling the incoming XML messages using JDOM
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      17. Handling the incoming XML messages using JAXB2
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      18. Validating the XML messages at the server side using an interceptor
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
    8. 2. Building Clients for SOAP Web-Services
      1. Introduction
      2. Setting up a Web-Service client development environment within Eclipse
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      3. Setting up a Web-Service client development environment using Maven
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      4. Creating a Web-Service client on HTTP transport
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Creating a Web-Service client on JMS transport
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      6. Creating a Web-Service client on E-mail transport
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also..
      7. Setting up a Web-Service on XMPP transport
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Creating a Web-Service client using XPath expressions
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      9. Creating a Web-Service client for a WS-Addressing endpoint
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      10. Transforming a Web-Service message using XSLT
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
    9. 3. Testing and Monitoring Web-Services
      1. Introduction
      2. Integration testing using Spring-JUnit support
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      3. Server-side integration testing using MockWebServiceClient
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      4. Client-side integration testing using MockWebServiceServer
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Monitoring TCP messages of a Web-Service using TCPMon
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      6. Monitoring and load/functional testing of a Web-Service using soapUI
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
    10. 4. Exception/SOAP Fault Handling
      1. Introduction
      2. Handling server-side exceptions by returning the exception's message as a SOAP fault string
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      3. Mapping exception class names to SOAP faults
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      4. Annotating exception classes with @SOAPFault
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      5. Writing your own exception resolvers in Spring-WS
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
    11. 5. Logging and Tracing of SOAP Messages
      1. Introduction
      2. Logging message payload manually
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      3. Logging both request and response SOAP Envelopes using log4j
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      4. Logging both request and response using Spring-WS's Interceptors
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      5. Using Eclipse IDE to debug a Spring-WS
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
    12. 6. Marshalling and Object-XML Mapping (OXM)
      1. Introduction
      2. Marshalling with JAXB2
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Marshalling with XMLBeans
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      4. Marshalling with JiBX
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      5. Marshalling with XStream
        1. Getting ready
        2. How to do it...
        3. How it works...
      6. Marshalling with MooseXML
        1. Getting ready
        2. How to do it...
        3. How it works...
      7. Creating a custom marshaller using XPath for conditional XML parsing
        1. Getting ready
        2. How to do it...
        3. How it works...
    13. 7. Securing SOAP Web-Services using XWSS Library
      1. Introduction
      2. Authenticating a Web-Service call using plain/digested username token
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also...
      3. Authenticating a Web-Service call using Spring security to authenticate a username token with a plain/digested password
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also...
      4. Authenticating a Web-Service call using a JAAS service to authenticate a username token
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also...
      5. Preparing pair and symmetric keystores
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also...
      6. Securing SOAP messages using digital signature
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also...
      7. Authenticating a Web-Service call using X509 certificate
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also...
      8. Encrypting/decrypting of SOAP messages
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also...
    14. 8. Securing SOAP Web-Services using WSS4J Library
      1. Introduction
      2. Authenticating a Web-Service call using a username token with a plain/digest password
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also...
      3. Authenticating a Web-Service call using Spring security to authenticate a username token with a plain/digest password
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also...
      4. Securing SOAP messages using a digital signature
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also...
      5. Authenticating a Web-Service call using an X509 certificate
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also...
      6. Encrypting/decrypting SOAP messages
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also...
    15. 9. RESTful Web-Services
      1. Introduction
      2. Setting up a Spring RESTful Web-Service using RESTful features in Spring MVC
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also...
      3. Using the REST Client tool to access Spring RESTful Web-Service
        1. Getting ready
        2. How to do it...
        3. See also...
      4. Setting up a Spring RESTful Web-Service using HTTP message conversion
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also...
      5. Creating a WS Client for the Spring RESTful Web-Service using Spring template classes
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more
        5. See also...
    16. 10. Spring Remoting
      1. Introduction
      2. Setting up Web-Services using RMI
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Setting up a servlet-based Web-Service using Hessian/Burlap, exposing business beans
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also...
      4. Setting up Web-Services using JAX-WS
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also...
      5. Exposing servlet-based Web-Services using Apache CXF
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also...
      6. Exposing Web-Services using JMS as the underlying communication protocol
        1. Getting ready
        2. How to do it...
        3. How it works...