Skip to content

Commit b94fad8

Browse files
gnodetclaude
andcommitted
CAMEL-23909: Fix namespace lookup in parseFaultCode
Look up the namespace prefix from the codeElement rather than faultElement so that namespace declarations on the <faultcode>/<Code> element itself are also visible. lookupNamespaceURI walks up the tree, so declarations on ancestor elements (including <Fault>) are still found. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4cc7369 commit b94fad8

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

  • components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws

components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfConsumer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ private static SoapFault extractFaultFromPayload(CxfPayload<?> payload) {
451451
Element childElem = (Element) child;
452452
String localName = childElem.getLocalName();
453453
if ("faultcode".equals(localName) || "Code".equals(localName)) {
454-
faultCode = parseFaultCode(element, childElem);
454+
faultCode = parseFaultCode(childElem);
455455
} else if ("faultstring".equals(localName) || "Reason".equals(localName)) {
456456
faultString = childElem.getTextContent();
457457
} else if ("detail".equals(localName) || "Detail".equals(localName)) {
@@ -469,7 +469,7 @@ private static SoapFault extractFaultFromPayload(CxfPayload<?> payload) {
469469
return fault;
470470
}
471471

472-
private static QName parseFaultCode(Element faultElement, Element codeElement) {
472+
private static QName parseFaultCode(Element codeElement) {
473473
String codeText = codeElement.getTextContent();
474474
if (codeText == null || codeText.isBlank()) {
475475
return null;
@@ -479,7 +479,9 @@ private static QName parseFaultCode(Element faultElement, Element codeElement) {
479479
if (colonIndex > 0) {
480480
String prefix = codeText.substring(0, colonIndex);
481481
String localPart = codeText.substring(colonIndex + 1);
482-
String namespaceURI = faultElement.lookupNamespaceURI(prefix);
482+
// Look up from codeElement (not faultElement) so that namespace declarations
483+
// on the <faultcode>/<Code> element itself are also visible
484+
String namespaceURI = codeElement.lookupNamespaceURI(prefix);
483485
if (namespaceURI != null) {
484486
return new QName(namespaceURI, localPart, prefix);
485487
}

0 commit comments

Comments
 (0)