From d93f80e316a866315d95861c17470bda07442c93 Mon Sep 17 00:00:00 2001 From: eshizhan Date: Sun, 24 Dec 2023 00:35:54 +0800 Subject: [PATCH] Support process SOAP 1.2 reply --- suds/bindings/binding.py | 5 +++++ tests/test_reply_handling.py | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/suds/bindings/binding.py b/suds/bindings/binding.py index 4af184cc..ad911f49 100644 --- a/suds/bindings/binding.py +++ b/suds/bindings/binding.py @@ -36,6 +36,7 @@ envns = ("SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/") +envns12 = ("SOAP-ENV", "http://www.w3.org/2003/05/soap-envelope") class Binding(object): @@ -146,8 +147,12 @@ def get_reply(self, method, replyroot): """ soapenv = replyroot.getChild("Envelope", envns) + if not soapenv: + soapenv = replyroot.getChild("Envelope", envns12) soapenv.promotePrefixes() soapbody = soapenv.getChild("Body", envns) + if not soapbody: + soapbody = soapenv.getChild("Body", envns12) soapbody = self.multiref.process(soapbody) nodes = self.replycontent(method, soapbody) rtypes = self.returned_types(method) diff --git a/tests/test_reply_handling.py b/tests/test_reply_handling.py index fc467869..83820b3d 100644 --- a/tests/test_reply_handling.py +++ b/tests/test_reply_handling.py @@ -481,6 +481,28 @@ def test_wrapped_sequence_output(): assert response.result3.__class__ is suds.sax.text.Text +def test_soap12_envns(): + # Prepare web service proxies. + client_bare = testutils.client_from_wsdl(testutils.wsdl("""\ + """, + output="fResponse")) + + assert not _isOutputWrapped(client_bare, "f") + + data = "The meaning of life." + def get_response(client, x): + return client.service.f(__inject=dict(reply=suds.byte_str(x))) + # Envelope namespace URI is SOAP 1.2 + response_bare = get_response(client_bare, """ + + + %s + +""" % (data,)) + assert response_bare.__class__ is suds.sax.text.Text + assert response_bare == data + + def _attributes(object): result = set() for x in object: