Monday, August 4, 2008

Spring Web Services Example

I ended up having time to finish up a really basic Spring Web Services example using JAXB for marshalling. It was very simple. Really once you have a project setup you will just have to focus on your XSD and business logic. It's nice having the marshalling/unmarshalling handled for you, but if the XML you're receiving becomes larger and you just need a specific part of it you can create a method that uses @XPathParam annotation in front of method variables to get a few values.

In the current example once everything is setup the client just has to make a call on the WebServiceTemplate passing in the request and receiving the response. Both are JAXB generated beans.

     PersonResponse response =
         (PersonResponse) wsTemplate.marshalSendAndReceive(request);


No comments: