Payloadvalidatinginterceptor schemas example

The code used in this article was developed in my work time at Redpill Linpro.

Details about how to create an XSD schema and JAXB classes are explained in this tutorial.

I will also briefly show exception handling and validation support in relation to SOAP faults.

Since Spring WS doesn’t use a service contract, you must know the request and response type.

The test below demonstrates how to create and instantiate a request object of a JAXB generated class, call the marshall Send And Receive method with it and how to cast the response object to an object of the JAXB generated response class.

The @Soap Fault annotation below helps the exception resolver to convert the exception to a Soap Fault.

Ant the Fault Code enum will be mapped to a fault-code element.

This is a different approach than for example CXF that generates an interface your implementation must implement.

The server implementation only has dependencies to the JAXB generated request and response classes. The implementation class must have the Spring @Endpoint annotation above the class name and the @Payload Root annotation above the method that will handle the web service request.

This blog article demonstrates how to use Spring WS as a client with JAXB for the data binding and how to add pre and post processing behaviour with interceptors.

Tags: , ,