I am running a web service in Cxf PAYLOAD mode and in one of the use cases I need to convert the body into Node (Element) and I am doing that by cxfpayload.getBody().get(0)
This makes the namespaces from nsMap to be copied on to the element. While doing so, if the nsMap contains a namespace prefix that is also part of the element's attribute, it is being overwritten in the addNamespace(Element element, Map<String, String> nsMap) method.
But when same prefix in soap Envelope and body contains different namespace values, that makes the body (XML) invalid.
Here is a sample soap request that contains same namespace prefix ns1 in soap:Envelope and soap:Body but contains different namespace values.
Now when I convert the payload into DOM Node, here is output XML namespace value for prefix ns1 is being replaced with the envelope.