简体   繁体   中英

How can I get past error in SOAP library zeep?

I am getting an error and cannot find a way to get around it - it completely stops my progress. How can I access this API with SOAP through Python?

import zeep

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

Error I get is 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 '

Python 3.6

The problem is the white space in the tag name 'AGGREGATE_SUPPRESSIONS ' - so you have to modify the utils.py file within the library itself. It's a simple fix which a workaround was presented on GitHub issue:

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

Add the following lines of code at the very beginning of the as_qname function.

Within 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM