Skip to content

Problem with namespace support in SOAP 11 Fault node #1254

Open
@brot

Description

@brot
  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>

Activity

added a commit that references this issue on Jul 28, 2023
b69d992
linked a pull request that will close this issue on Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @brot

      Issue actions

        Problem with namespace support in SOAP 11 Fault node · Issue #1254 · mvantellingen/python-zeep