-
Jul 28th, 2006, 08:32 AM
#1
Spring-WS: Odd XML in SOAP envelope
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)
throws Exception
{
WebServiceMessage request = messageContext.getRequest();
Object requestObject = unmarshaller.unmarshal(request.getPayloadSource()) ;
if(logger.isDebugEnabled())
logger.debug("Unmarshalled payload request to [" + requestObject + "]");
Object responseObject = invokeInternal(requestObject);
marshaller.marshal(responseObject, new StreamResult(System.out));
if(responseObject != null)
{
if(logger.isDebugEnabled())
logger.debug("Marshalling [" + responseObject + "] to response payload");
WebServiceMessage response = messageContext.getResponse();
marshaller.marshal(responseObject, response.getPayloadResult());
System.out.println("****************************** ****");
response.writeTo(System.out);
}
}
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"?>
<tns:EvaluateHandResponse xmlns:tns="http://www.habuma.com/poker/schemas">
<tns:handName xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="java:java.lang.String">FLUSH</tns:handName>
</tns:EvaluateHandResponse>
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):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<tns: xmlns:tns="http://www.habuma.com/poker/schemas">
<tns: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="java:java.lang.String"
xmlns:tns="handName">FLUSH</tns:>
</tns:>
</soapenv:Body>
</soapenv:Envelope>
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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules