axiom cannot retrieve default namespace for OMElement
-----------------------------------------------------
Key: WSCOMMONS-166
URL: https://issues.apache.org/jira/browse/WSCOMMONS-166
Project: WS-Commons
Issue Type: Bug
Components: AXIOM
Reporter: Mike Rheinheimer
Attachments: patch.txt
The patch explains it all. :)
The soap message we try to use in the patch is:
// missing namespace for faultcode value
private final static String sampleSOAP12FaultEnvelope2 =
//"<?xml version='1.0' encoding='UTF-8'?>"
"<env:Envelope xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\">"
+ "<env:Body>"
+ "<env:Fault>"
+ "<env:Code><env:Value>Sender</env:Value></env:Code>"
+ "<env:Reason><env:Text lang=\""+ Locale.getDefault().getLanguage()
+"\">"
+ faultString + "sampleSOAP12FaultEnvelope2</env:Text></env:Reason>"
+ "</env:Fault>"
+ "</env:Body>"
+ "</env:Envelope>";
Notice the fault code value "Sender" has no prefix "env" in this message. It
seems like axiom is not setting a default namespace without a prefix. I tried
adding some code to OMTextImpl:
public OMNamespace getNamespace() {
// If the namespace has already been determined, return it
// Otherwise calculate the namespace if the text contains a colon and
is not detached.
if (calcNS) {
return textNS;
} else {
calcNS = true;
if (getParent() != null) {
String text = getTextFromProperPlace();
if (text != null) {
int colon = text.indexOf(':');
if (colon > 0) {
textNS = ((OMElementImpl) getParent()).
findNamespaceURI(text.substring(0,colon));
if (textNS != null) {
charArray = null;
value = text.substring(colon+1);
}
}
// NEW
else {
textNS = ((OMElementImpl)
getParent()).findNamespaceURI("");
if (textNS != null) {
charArray = null;
value = text.substring(colon+1);
}
// END NEW
}
}
}
}
return textNS;
}
This of course calls findNamespaceURI with a blank prefix. However, there is
no namespace with a blank prefix in the map of namespaces. So, we thought this
might be due to the first SOAPElement constructor setting a local 'ns' field
with the namespace from the parent instead of calling setNamespace(). So I
tried changing it:
if (extractNamespaceFromParent) {
//this.ns = parent.getNamespace();
setNamespace(parent.getNamespace());
}
This also did not work, however, because parent.getNamespace() just returns the
already-prefixed namespace. It does not add another entry to the namespace map.
See patch for testcase.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]