Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with namespace support in SOAP 11 Fault node #1254

Open
brot opened this issue Aug 23, 2021 · 0 comments · May be fixed by #1386
Open

Problem with namespace support in SOAP 11 Fault node #1254

brot opened this issue Aug 23, 2021 · 0 comments · May be fixed by #1386

Comments

@brot
Copy link

brot commented Aug 23, 2021

  1. zeep==4.1.0
  2. It's not a public WSDL so i can't provide it; but it's also not needed to reproduce the bug
  3. Runnable example:

The bug was introduced with the namespace support in SOAP 11 Fault node (0704fb5).
If you add the following lines to the test_soap11_process_error test in tests/test_wsdl_soap.py you are able to reproduce the problem

    responseWithEmptyNamespaceInFault = load_xml(
        """
        <soapenv:Envelope
            xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
            xmlns="http://example.com/my/schema">
          <soapenv:Body>
            <soapenv:Fault>
              <faultcode xmlns="">fault-code-withEmptyNamespace</faultcode>
              <faultstring xmlns="">fault-string-withEmptyNamespace</faultstring>
              <detail xmlns="">
                <myFaultDetails xmlns="http://example.com/my/schema">
                  <message>detail-message-withNamespace</message>
                  <errorcode>detail-code-withNamespace</errorcode>
                </myFaultDetails>
              </detail>
            </soapenv:Fault>
          </soapenv:Body>
        </soapenv:Envelope>
    """
    )

    try:
        binding.process_error(responseWithEmptyNamespaceInFault, None)
        assert False
    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"
        )

The test output with this newly added test

>           assert exc.message == "fault-string-withEmptyNamespace"
E           AssertionError: assert None == 'fault-string-withEmptyNamespace'
E            +  where None = Fault(None).message

This Fault Response is used by an external API and the maintainer of these API told me that this empty namespaces are valid and pointed me to https://www.w3.org/TR/REC-xml-names/#scoping-defaulting and there you can also find this example

The attribute value in a default namespace declaration MAY be empty. This has the same effect, within the scope of the declaration, of there being no default namespace.

<?xml version='1.0'?>
<Beers>
  <!-- the default namespace inside tables is that of HTML -->
  <table xmlns='http://www.w3.org/1999/xhtml'>
   <th><td>Name</td><td>Origin</td><td>Description</td></th>
   <tr> 
     <!-- no default namespace inside table cells -->
     <td><brandName xmlns="">Huntsman</brandName></td>
     <td><origin xmlns="">Bath, UK</origin></td>
     <td>
       <details xmlns=""><class>Bitter</class><hop>Fuggles</hop>
         <pro>Wonderful hop, light alcohol, good summer beer</pro>
         <con>Fragile; excessive variance pub to pub</con>
         </details>
        </td>
      </tr>
    </table>
  </Beers>
dpoisl pushed a commit to dpoisl/python-zeep that referenced this issue Jul 28, 2023
Parsing soap faults falls back to extracting attributes without a
namespace, if it can't find a namespaced attribute.

Fixes mvantellingen#1254
@dpoisl dpoisl linked a pull request Jul 28, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant