Skip to content

saaj-impl 1.5.3 regression when cloning a document #184

@fpavageau

Description

@fpavageau

Context

In a Spring WS context, I have an integration test which fails when saaj-impl is upgraded from 1.5.2 to 1.5.3, because the mock server fails to match the actual request with the expected request. That part is done by spring-ws-test using xmlunit, which clones the incoming SOAPDocument to be able to normalize it against the expected request. With 1.5.3, xmlunit fails to use the cloned document, as it throws an IllegalArgumentException with Cannot find SOAP wrapper for element [SOAP-ENV:Envelope: null]:

java.lang.IllegalArgumentException: Cannot find SOAP wrapper for element [SOAP-ENV:Envelope: null]
	at com.sun.xml.messaging.saaj.soap.SOAPDocumentImpl.find(SOAPDocumentImpl.java:590)
	at com.sun.xml.messaging.saaj.soap.SOAPDocumentImpl.find(SOAPDocumentImpl.java:578)
	at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.lookForEnvelope(SOAPPartImpl.java:155)
	at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:135)
	at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.getDocumentElement(SOAPPartImpl.java:430)
	at org.custommonkey.xmlunit.DifferenceEngine.compareNode(DifferenceEngine.java:191)
	at org.custommonkey.xmlunit.DifferenceEngine.compare(DifferenceEngine.java:130)
	at org.custommonkey.xmlunit.Diff.compare(Diff.java:241)
	at org.custommonkey.xmlunit.Diff.appendMessage(Diff.java:364)
	at org.custommonkey.xmlunit.Diff.toString(Diff.java:378)
	at org.springframework.ws.test.support.matcher.SoapEnvelopeDiffMatcher.match(SoapEnvelopeDiffMatcher.java:61)
	at org.springframework.ws.test.support.matcher.AbstractSoapMessageMatcher.match(AbstractSoapMessageMatcher.java:40)
	at org.springframework.ws.test.client.WebServiceMessageMatcherAdapter.match(WebServiceMessageMatcherAdapter.java:43)
	at org.springframework.ws.test.client.MockSenderConnection.send(MockSenderConnection.java:76)
	at org.springframework.ws.client.core.WebServiceTemplate.sendRequest(WebServiceTemplate.java:658)
	at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:606)
	at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:555)
	at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:390)

Analysis

The difference in behavior between 1.5.2 and 1.5.3 comes from #166, which changes SOAPPartImpl.cloneNode() to call the doCloneNode() method: the cloned SOAPPartImpl instance has no envelope set, and it then fails to re-create it (when getEnvelope() is called, in the stacktrace above), apparently because the owner document misses some userData.

Reproducing the issue

I'll try to create a simple project reproducing the issue:

  1. create a SoapMessage
  2. get its document (the SOAPPart) and clone it
  3. call getDocumentElement() on the clone and fail

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions