Spring Web Services 2 Cookbook

Cookbook

Hamidreza Sattari, Shameer KunjumohamedFebruary 2012

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.

$29.99

$49.99

RRP $29.99

RRP $49.99

eBook

Print + eBook

Want this title & more?

$16.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Who This Book Is For

This book is for Java/J2EE developers. As the books covers a variety of topics in Web-Service development, it will serve as a reference guide to those already familiar with Web-Services. Beginners can also use this book to gain real-world experience of Web-Service development.

Table of Contents

Chapter 1: Building SOAP Web-Services

Introduction

Using Maven for building and running a Spring-WS project

Creating a data contract

Setting up a Web-Service using DispatcherServlet

Simplifying the creation of a Web-Service using MessageDispatcherServlet

Setting up a Web-Service on JMS transport

Setting up a Web-Service on E-mail transport

Setting up a Web-Service on embedded HTTP transport

Setting up Spring-WS on XMPP transport

Setting up a contract-first Web-Service

Setting up a simple endpoint mapping for the Web-Service

Setting up an endpoint by annotating the payload-root

Setting up a transport-neutral WS-Addressing endpoint

Setting up an endpoint using an XPath expression

Handling the incoming XML messages using DOM

Handling the incoming XML messages using JDOM

Handling the incoming XML messages using JAXB2

Validating the XML messages at the server side using an interceptor

Chapter 2: Building Clients for SOAP Web-Services

Introduction

Setting up a Web-Service client development environment within Eclipse

Setting up a Web-Service client development environment using Maven

Creating a Web-Service client on HTTP transport

Creating a Web-Service client on JMS transport

Creating a Web-Service client on E-mail transport

Setting up a Web-Service on XMPP transport

Creating a Web-Service client using XPath expressions

Creating a Web-Service client for a WS-Addressing endpoint

Transforming a Web-Service message using XSLT

Chapter 3: Testing and Monitoring Web-Services

Introduction

Integration testing using Spring-JUnit support

Server-side integration testing using MockWebServiceClient

Client-side integration testing using MockWebServiceServer

Monitoring TCP messages of a Web-Service using TCPMon

Monitoring and load/functional testing of a Web-Service using soapUI

Chapter 4: Exception/SOAP Fault Handling

Introduction

Handling server-side exceptions by returning the exception's message as a SOAP fault string

Mapping exception class names to SOAP faults

Annotating exception classes with @SOAPFault

Writing your own exception resolvers in Spring-WS

Chapter 5: Logging and Tracing of SOAP Messages

Introduction

Logging message payload manually

Logging both request and response SOAP Envelopes using log4j

Logging both request and response using Spring-WS's Interceptors

Using Eclipse IDE to debug a Spring-WS

Chapter 6: Marshalling and Object-XML Mapping (OXM)

Introduction

Marshalling with JAXB2

Marshalling with XMLBeans

Marshalling with JiBX

Marshalling with XStream

Marshalling with MooseXML

Creating a custom marshaller using XPath for conditional XML parsing

Chapter 7: Securing SOAP Web-Services using XWSS Library

Introduction

Authenticating a Web-Service call using plain/digested username token

Authenticating a Web-Service call using Spring security to authenticate a username token with a plain/digested password

Authenticating a Web-Service call using a JAAS service to authenticate a username token

Preparing pair and symmetric keystores

Securing SOAP messages using digital signature

Authenticating a Web-Service call using X509 certificate

Encrypting/decrypting of SOAP messages

Chapter 8: Securing SOAP Web-Services using WSS4J Library

Introduction

Authenticating a Web-Service call using a username token with a plain/digest password

Authenticating a Web-Service call using Spring security to authenticate a username token with a plain/digest password

Securing SOAP messages using a digital signature

Authenticating a Web-Service call using an X509 certificate

Encrypting/decrypting SOAP messages

Chapter 9: RESTful Web-Services

Introduction

Setting up a Spring RESTful Web-Service using RESTful features in Spring MVC

Using the REST Client tool to access Spring RESTful Web-Service

Setting up a Spring RESTful Web-Service using HTTP message conversion

Creating a WS Client for the Spring RESTful Web-Service using Spring template classes

Chapter 10: Spring Remoting

Introduction

Setting up Web-Services using RMI

Setting up a servlet-based Web-Service using Hessian/Burlap, exposing business beans

Setting up Web-Services using JAX-WS

Exposing servlet-based Web-Services using Apache CXF

Exposing Web-Services using JMS as the underlying communication protocol

What You Will Learn

Setting up SOAP Web-Services using various protocols such as HTTP, JMS, XMPP, Email and so on

Implementing Web-Service's Endpoint using technologies such as DOM, JDOM, XPATH, and Marshaller

Testing Web-Services using latest features of Spring-WS

Creating and monitoring automated testing using tools such as soapUI and TCPMon

Marshalling and Un-Marshalling using Jaxb2, XMLbeans, Xstream and other technologies

Implement a Web-Service using Spring-Remoting on RMI, Hessian/Burlap, JAX-WS, JMS technologies and a Web-Service using Apache CXF on JAXWS front-end

Developing REST Web-Service server and client using Spring RESTful Support

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.

Authors

Hamidreza Sattari

Hamidreza Sattari started software development in 2002. He has been involved in several areas of Software Engineering--programming to architecture to management. His area of interest has been integration among enterprise applications and SOA.
Hamidreza Sattari earned his MSc in Software Engineering in 2008 from Herriot Watt University, UK and his Bachelor's Degree in 1994 in Electrical Engineering (Electronics) from Tehran Azad University, Iran. In recent years his research area of interest has been scientific data mining, using algorithms and statistical techniques in pattern recognition, estimation and machine learning.

Shameer Kunjumohamed

Shameer Kunjumohamed is a software architect, specialized in enterprise application integrations and SOA. He is well versed in J2EE and Microsoft.Net platforms. He is interested in various mobile platforms including Android, Black berry and other cross-platform mobile frameworks these days.
After graduating from Calicut University, India in 2000, Shameer handled different roles in software engineering. He graduated his Masters Degree in Software Engineering from Herriot Watt University, UK from Dubai International Academic City in 2009. At present he works as a Solutions Architect in Dubai, UAE, and is a guest lecturer in the same university for the Masters students in Information Technology.

Alerts & Offers

Series & Level

We understand your time is important. Uniquely amongst the major publishers, we seek to develop and publish the broadest range of learning and information products on each technology. Every Packt product delivers a specific learning pathway, broadly defined by the Series type. This structured approach enables you to select the pathway which best suits your knowledge level, learning style and task objectives.

Learning

As a new user, these step-by-step tutorial guides will give you all the practical skills necessary to become competent and efficient.

Beginner's Guide

Friendly, informal tutorials that provide a practical introduction using examples, activities, and challenges.

Essentials

Fast paced, concentrated introductions showing the quickest way to put the tool to work in the real world.

Cookbook

A collection of practical self-contained recipes that all users of the technology will find useful for building more powerful and reliable systems.

Blueprints

Guides you through the most common types of project you'll encounter, giving you end-to-end guidance on how to build your specific solution quickly and reliably.

Mastering

Take your skills to the next level with advanced tutorials that will give you confidence to master the tool's most powerful features.

Starting

Accessible to readers adopting the topic, these titles get you into the tool or technology so that you can become an effective user.

Progressing

Building on core skills you already have, these titles share solutions and expertise so you become a highly productive power user.