Book Image

Mastering Spring Application Development

By : Anjana Mankale
Book Image

Mastering Spring Application Development

By: Anjana Mankale

Overview of this book

Table of Contents (19 chapters)
Mastering Spring Application Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Spring Web Services with JAXB marshalling for request


In this section, let's look at developing a simple web service using the Spring Web Service framework. We need JAXB for marshalling and unmarshalling the XML request. The Spring Web Service supports contract first web service. We need to design a XSD/WSDL first and then launch the web service.

We are creating an author web service which will give us a list of authors.

  1. Configuring the web.xml file: Let us first do a web service configuration in a web.xml file. We need to configure the Spring Web Service servlet. The Message Dispatcher servlet needs to be defined and the URL patterns it will handle. The contextConfigLocation is specified instead of allowing the default (/WEB-INF/spring-ws-servlet.xml) because this location makes the configuration easier to share with the unit test.

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns="http://java.sun.com/xml/ns/javaee" 
     ...