SAAJ 1.3: SoapBody.addDocument throws NAMESPACE_ERR
Hello,
I'm trying to add a Document to a SoapBody via the addDocument method.
The node I'm adding looks like this:
<ns1:DSDOrderRequest xmlns="mooncompany"
xmlns:ns1="http://hnsp.inf-bb.uni-jena.de/SWS-Challenge"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...
My Problem is, I get a namespace error:
org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
The reason is, my node is added using the name "ns1:DSDOrderRequest" but no namespace URI is specified.
I debugged this using SourceCode and jar file from https://saaj.dev.java.net/ (Version 1.3) and found the following lines of code:
com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl
boolean domLevel20 = source.getOwnerDocument().getImplementation().hasFeature("XML", "2.0");
// Create element according to namespace support/qualification.
if(domLevel20 == false || source.getLocalName() == null)
newElement = createElement(source.getNodeName());
else
newElement = createElementNS(source.getNamespaceURI(),
source.getNodeName());
and the first line is executed which explains why the node is added using the name "ns1:DSDOrderRequest" instead of the name "DSDOrderRequest" with the correct prefix and namespace URI.
What I don't know is how to deal with this.
Any help would be greatly appreciated. Took me a lot of time to investigate this issue already :-(
Thanks in advance,
Uli

