apache > ws.apache
Apache Muse
 

Apache Muse - Default Namespaces in SOAP Message Cause Undefined Behavior

If you try to send SOAP messages with XML elements that use the default namespace or empty prefix constructs, you will often find yourself tracking down odd behavior in the form of silent and unpredictable errors (those which have no message or seem to fail only some of the time). Default namespaces and empty prefixes look like this:

<!-- This element is using a default namespace. -->
<MyElement xmlns="http://example.com"/>

<!-- This element is using an empty prefix. -->
<:MyElement xmlns:="http://example.com"/>

These problems are caused by the XML parser, which does not handle these constructs properly. The parser is not part of the Apache Muse project, and even if the bug were fixed, it is likely that the JDK you are using includes a version of the parser already and you will not be able to modify it because of support or legal concerns.

The easiest solution to this problem is to just use prefixes for your XML elements. When providing QNames to the XmlUtils methods, make sure to use the three-parameter constructor, which allows you to specify the prefix that will map to your QName's namespace. Creating QNames with prefixes is only necessary when creating a new element, not when searching for an existing element.