[SWS-392] AbstractMarshallingPayloadEndpoint and XStreamMarshaller produces malformed response body Created: 09/Jul/08  Updated: 04/May/12  Resolved: 21/Jul/08

Status: Closed
Project: Spring Web Services
Component/s: OXM
Affects Version/s: 1.5.2
Fix Version/s: 1.5.4

Type: Bug Priority: Major
Reporter: Robert Novotny Assignee: Tareq Abedrabbo
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows XP,. Jetty 5, XStream 1.3


Attachments: Text File SWS-392.patch    

 Description   

Marshalling and unmarshalling of objects to XML payloads using AbstractMarshallingPayloadEndpoint and XStreamMarshaller seems to generated malformed SOAP Message when using XStream 1.2.1 or newer (XStream 1.2 works without problems).

The fundamental method of my endpoint looks like this:
Code:

protected Object invokeInternal(Object object) throws Exception {

MovieReservation movieReservationRequest = (MovieReservation) object;

ReservationConfirmation confirmation = new ReservationConfirmation();
confirmation.setId(new Date().getDate());
confirmation.setSeatIds(new int[]

{1, 2, 3, 4}

);

return confirmation;
}

The SOAP response, which is malformed, looks as follows:
Code:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="..../">
<SOAP-ENV:Header/>
<SOAP-ENV:Body/>
<ReservationConfirmation>
<id>23</id>
<seatIds>
<int>1</int>
<int>2</int>
<int>3</int>
<int>4</int>
</seatIds>
</ReservationConfirmation>
</SOAP-ENV:Envelope>

Notice the empty header and empty body and the ReservationConfirmation element following the body element (which is incorrect, since this element should be within the body).

I suspect the Spring org.s.x.oxm.XStreamWriter and its method marshalDomDone which contains the following lines
Code:

else if (node instanceof Element)

{ streamWriter = new DomWriter((Element) node); }

However, sometimes between XStream 1.2 and XStream 1.3 the functionality of DomWriter has changed. This is described on the XStream mailing list in the "DOMWriter uses root element for marshalling instead of specified element" topic [1]

The suggested change is described in that post:"To write into an arbitrary node you have to use the constructor DomWriter(Element, Document, XmlFriendlyReplacer)."

Shouldn't the XStreamMarshall use the suggested three-param constructor instead of the default?

[1] http://www.nabble.com/DOMWriter-uses-root-element-for-marshalling-instead-of-specified-element-td16088975.html#a16088975



 Comments   
Comment by Tareq Abedrabbo [ 15/Jul/08 ]

Patch + unit test.
Robert, thanks for the detailed description.

Comment by Arjen Poutsma [ 21/Jul/08 ]

Fixed. Thanks, both of you.

Comment by Arjen Poutsma [ 04/May/12 ]

Closing old issues

Generated at Mon Dec 18 07:01:37 UTC 2017 using JIRA 6.4.14#64029-sha1:ae256fe0fbb912241490ff1cecfb323ea0905ca5.