diff --git a/src/zeep/wsdl/bindings/soap.py b/src/zeep/wsdl/bindings/soap.py index 3a5e5433..c9f1ed27 100644 --- a/src/zeep/wsdl/bindings/soap.py +++ b/src/zeep/wsdl/bindings/soap.py @@ -321,8 +321,15 @@ def process_error(self, doc, operation): detail=etree_to_string(doc), ) - def get_text(name): + def get_node(name): child = fault_node.find(name, namespaces=fault_node.nsmap) + if child is not None: + return child + child = fault_node.find(name) + return child + + def get_text(name): + child = get_node(name) if child is not None: return child.text @@ -330,7 +337,7 @@ def get_text(name): message=get_text("faultstring"), code=get_text("faultcode"), actor=get_text("faultactor"), - detail=fault_node.find("detail", namespaces=fault_node.nsmap), + detail=get_node("detail"), ) def _set_http_headers(self, serialized, operation): diff --git a/tests/test_wsdl_soap.py b/tests/test_wsdl_soap.py index b8a40b28..d9efe852 100644 --- a/tests/test_wsdl_soap.py +++ b/tests/test_wsdl_soap.py @@ -95,6 +95,39 @@ def test_soap11_process_error(): "utf-8" ) + responseWithEmptyNamespaceInFault = load_xml( + """ + + + + fault-code-withEmptyNamespace + fault-string-withEmptyNamespace + + + detail-message-withNamespace + detail-code-withNamespace + + + + + + """ + ) + + try: + binding.process_error(responseWithEmptyNamespaceInFault, None) + except Fault as exc: + assert exc.message == "fault-string-withEmptyNamespace" + assert exc.code == "fault-code-withEmptyNamespace" + assert exc.actor is None + assert exc.subcodes is None + assert "detail-message-withNamespace" in etree.tostring(exc.detail).decode( + "utf-8" + ) + + def test_soap12_process_error(): response = """