当实际响应包含数据时,Zeep 4.0 是否应该返回 None 结果?

问题描述

我使用的是 Python 3 和 Zeep 4.0。我正在尝试为邮件列表系统“SYMPA”使用 SOAP API。命令之一是info。来自

python -m zeep https://lists.company.com/lists/wsdl

我看到 info 命令定义为:

info(listName: xsd:string) -> return: ns0:listType

从上面的命令列表部分我看到 ns0:listType 被定义为:

ns0:listType(listAddress: xsd:string,homepage: xsd:string,isSubscriber: xsd:boolean,isOwner: xsd:boolean,isEditor: xsd:boolean,subject: xsd:string,firstBounceDate: xsd:int,lastBounceDate: xsd:int,bounceCount: xsd:int,bounceCode: xsd:int)

如果我通过 Zeep 发出该命令,结果代码为 200,但返回的值为 None

我已通过 Zeep 库将命令跟踪到 .../bindings/soap.py。在我的版本中,第 127 行 client.transport.post_xml()调用并返回响应。响应的 content 以漂亮的格式包含以下内容

b'<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <infoResponse xmlns="urn:sympasoap">
            <s-gensym163>
                <isOwner xsi:type="xsd:boolean">true</isOwner>
                <homepage xsi:type="xsd:string">https://lists.company.com/lists/info/my-list</homepage>
                <subject xsi:type="xsd:string">my-list</subject>
                <listAddress xsi:type="xsd:string">my-list@lists.company.com</listAddress>
            </s-gensym163>
        </infoResponse>
    </soap:Body>
</soap:Envelope>'

我注意到定义中的所有响应元素都没有出现在回复中。我无法控制。

这会将我带到调用 .../bindings/process_replyparse_xml() 行 204。在调用 loader.py 的第 50 行,我进入了 fromstring()。然后进入 ...site-packages/defusedxml/lxml.py 第 143 行:

rootelement = _etree.fromstring(text,parser,base_url=base_url)

** 编辑 **

lxml 解析器定义为:

parser = etree.XMLParser(
            remove_comments=True,resolve_entities=False,recover=recover,# False
            huge_tree=settings.xml_huge_tree,# False
        )

base_url 值为 https://lists.company.com/lists/wsdl

我不能再下台了。 rootelement 包含:

rootelement = {_Element: 1} <Element {http://schemas.xmlsoap.org/soap/envelope/}Envelope at 0x6251728>
 attrib = {_Attrib: 1} {'{http://schemas.xmlsoap.org/soap/envelope/}encodingStyle': 'http://schemas.xmlsoap.org/soap/encoding/'}
 base = {nonetype} None
 nsmap = {dict: 4} {'xsi': 'http://www.w3.org/2001/XMLSchema-instance','soapenc': 'http://schemas.xmlsoap.org/soap/encoding/','xsd': 'http://www.w3.org/2001/XMLSchema','soap': 'http://schemas.xmlsoap.org/soap/envelope/'}
  'xsi' = {str} 'http://www.w3.org/2001/XMLSchema-instance'
  'soapenc' = {str} 'http://schemas.xmlsoap.org/soap/encoding/'
  'xsd' = {str} 'http://www.w3.org/2001/XMLSchema'
  'soap' = {str} 'http://schemas.xmlsoap.org/soap/envelope/'
  __len__ = {int} 4
 prefix = {str} 'soap'
 sourceline = {int} 1
 tag = {str} '{http://schemas.xmlsoap.org/soap/envelope/}Envelope'
 tail = {nonetype} None
 text = {nonetype} None

我没有看到任何“错误”,但我也没有得到我认为应该得到的。

我是否配置错误?我正在应用的唯一设置是:Settings(strict=False)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)