W3CDOMStreamWriter does not pop namespace context during writeEndElement()
As the result parent namespace is evaluated improperly during generation of message from DOM (WSS4J in my case)
in org.codehaus.xfire.aegis.stax.ElementWriter.writeStartElement() - getUniquePrefix would use the previous (already closed) element to compute the prefix, it will be evaluated improperly for every other element of the response (see down below)
Following patch in writeEndElement() resolves the issue for me:
Index: org/codehaus/xfire/util/stax/W3CDOMStreamWriter.java
===================================================================
— org/codehaus/xfire/util/stax/W3CDOMStreamWriter.java
+++ org/codehaus/xfire/util/stax/W3CDOMStreamWriter.java
@@ -117,4 +117,6 @@
else
currentNode = null;
+
+ ((W3CNamespaceContext)context).setElement(currentNode);
}
problematic response is:
<helloResponse xmlns="http://DefaultNamespace" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<out>
<par0 xmlns="http://name.pkg.some">0</par0>
<par1>1</par1>
<par2 xmlns="http://name.pkg.some">2</par2>
<s1>S1Value</s1>
<s2 xmlns="http://name.pkg.some">S2Value</s2>
<s3>S3Value</s3>
</out>
</helloResponse>