Skip to content

Commit

Permalink
Merge pull request #96 from eshizhan/patch-2
Browse files Browse the repository at this point in the history
Support process SOAP 1.2 reply
  • Loading branch information
phillbaker committed Mar 2, 2024
2 parents ca41721 + d93f80e commit 7924301
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions suds/bindings/binding.py
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
22 changes: 22 additions & 0 deletions tests/test_reply_handling.py
Expand Up @@ -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("""\
<xsd:element name="fResponse" type="xsd:string"/>""",
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, """<?xml version="1.0"?>
<Envelope xmlns="http://www.w3.org/2003/05/soap-envelope">
<Body>
<fResponse xmlns="my-namespace">%s</fResponse>
</Body>
</Envelope>""" % (data,))
assert response_bare.__class__ is suds.sax.text.Text
assert response_bare == data


def _attributes(object):
result = set()
for x in object:
Expand Down

0 comments on commit 7924301

Please sign in to comment.