Spring Book – Chapter 16 – Web Services – Spring WS

Configure Spring WS

To configure Spring WS in a Spring MVC application, do the following steps as detailed in the following section.

First, configure MessageDispatcherServlet in web.xml – Listing 16-3 shows configuring Spring WS servlet, org.springframework.ws.transport.http.MessageDispatcherServlet in web.xml file as shown below.

Listing 16-3. MessageDispatcherServlet configuration in web.xml

Next, configure Spring configuration file – Configure the various configuration in the Spring configuration files as beans. Configure the following beans as shown in Listing 16-4 below.

Listing 16-4. Configuraing Spring configuration beans


There are various endpoints available which can be configured according to your application requirement. They are as below:

  • DOM endpoints
  • Marshalling endpoints
  • XPath endpoints

Based on the message the web services receive, the endpoints can be categorized as follows:

  • Message endpoints – full message will be delivered
  • Payload endpoints – only payload will be delivered

Once you decide on the appropriate endpoint for your application, you will have to configure the endpoint in your Spring configuration file as shown in Listing 16-5 below. XPath endpoint will be used as an example for defining endpoints. Listing 16- 6 shows the endpoint Java class using XPath endpoint. Spring will use your endpoint PayloadRoot annotation to match WS request with appropriate method.

Listing 16-5. Java class for configuring endpoint

Listing 16-6. Configuring endpoint in Spring configuration file

Page Visitors: 11132

The following two tabs change content below.
Tomcy John

Tomcy John

Blogger & Author at javacodebook
He is an Enterprise Java Specialist holding a degree in Engineering (B-Tech) with over 10 years of experience in several industries. He's currently working as Principal Architect at Emirates Group IT since 2005. Prior to this he has worked with Oracle Corporation and Ernst & Young. His main specialization is on various web technologies and acts as chief mentor and Architect to facilitate incorporating Spring as Corporate Standard in the organization.
Tomcy John

Latest posts by Tomcy John (see all)

Leave a Reply

Your email address will not be published. Required fields are marked *