0

我遇到了一个错误,无法找到绕过它的方法 - 它完全阻止了我的进步。如何通过 Python 使用 SOAP 访问此 API?

import zeep

endpoint_soap = 'http://api4.ibmmarketingcloud.com/SoapApi?wsdl'
client = zeep.Client(endpoint_soap)

我得到的错误是 ValueError:

....
File "src/lxml/etree.pyx", line 1826, in lxml.etree.QName.__init__
File "src/lxml/apihelpers.pxi", line 1626, in 
lxml.etree._tagValidOrRaise
ValueError: Invalid tag name 'AGGREGATE_SUPPRESSIONS '

蟒蛇 3.6

4

1 回答 1

1

问题是标签名称“AGGREGATE_SUPPRESSIONS”中的空格 - 因此您必须修改库本身中的 utils.py 文件。这是一个简单的修复,在 GitHub 问题上提出了一种解决方法:

https://github.com/mvantellingen/python-zeep/issues/594

在 as_qname 函数的最开头添加以下代码行。

在 zeep > utils.py 中:

def as_qname(value, nsmap, target_namespace=None):
    ## Workaround: if any leading and/or ending whitespaces are present, remove them
    ## strip whitespaces
    value = value.strip()
    ## End of workaround
于 2018-05-09T16:19:18.120 回答