I've rattled my brain on this one for almost a week and finally decided to see if someone else could help me out...
Basically, I have written a simple web-service using Spring-WS and a Castor marshaller. I've made a small tweak to AbstractMarshallingPayloadEndpoint so that I can see what my response is being marshalled to. The new invoke() method looks like this:
public final void invoke(MessageContext messageContext)
WebServiceMessage request = messageContext.getRequest();
Object requestObject = unmarshaller.unmarshal(request.getPayloadSource()) ;
logger.debug("Unmarshalled payload request to [" + requestObject + "]");
Object responseObject = invokeInternal(requestObject);
marshaller.marshal(responseObject, new StreamResult(System.out));
if(responseObject != null)
logger.debug("Marshalling [" + responseObject + "] to response payload");
WebServiceMessage response = messageContext.getResponse();
The first thing I do is use the marshaller to marshal the message to System.out. The result of that looks like this (edited for readability's sake):
<?xml version="1.0" encoding="UTF-8"?>
And this is exactly what I expected.
Then, I let the object be marshalled into the WebServiceMessage's response payload message and use the writeTo() method to send the message to System.out. I get this result (again, formatted for readability):
Notice that the body XML is completely messed up. First off, the elements only have a "tns" namespace...no element name. Then, the xmlns:tns on the inner element is set to what should be the element's name.
I've dug around in the Spring-WS source code, ran things through a debugger, and lost my patience plenty over this one. My current line of thinking is that somehow the SAAJ implementation is screwing up the message...but I've tried by Axis' SAAJ and the Sun SAAJ implementation that comes with Spring-WS and the result is the same.
Again, keep in mind that the marshaller seems to be working perfectly. The message gets hosed somewhere between the marshaller and the WebServiceMessage's payload result.
Anybody run into this before? Anyone have any clues? Is it something I'm doing wrong?