python-zeep
python-zeep copied to clipboard
Empty array/list parses as None
- zeep version 3.2.0
- WSDL: https://gist.github.com/apexo/f1ffbbb37764032bebb1936c3e8e8c25
- Script: https://gist.github.com/apexo/372f69deee0a132458d506e78e8bea3d
So I have a WSDL with a request that contains an optional repeatable element <list-entry> (minOccurs=0, maxOccours=unbounded) that is wrapped in another element (<list-wrapper>) .
The sample script parses this document:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<testRequest>
<list-wrapper>
<list-entry>1</list-entry>
</list-wrapper>
</testRequest>
</env:Body>
</env:Envelope>
as follows (kind of expected):
{
'list-wrapper': {
'list-entry': [
'1'
]
},
'dummy': None
}
while
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<testRequest>
<list-wrapper>
</list-wrapper>
</testRequest>
</env:Body>
</env:Envelope>
is parsed as
{
'list-wrapper': None,
'dummy': None
}
I find this a bit surprising. IMO, the latter should parse as
{
'list-wrapper': {
'list-entry': []
},
'dummy': None
}
Otherwise it is impossible to tell whether <list-wrapper> itself was present in the request or not (if <list-wrapper> were optional in the WSDL which it is not in the reduced sample). But whether the wrapper is present or not sometimes makes a semantic difference. And that's my problem. Thank you for your attention.