python - SOAP suds 库类型未找到错误

python - SOAP suds library Type Not Found Error

我正在尝试为 Textbroker API 创建 Python 客户端,但无法访问其 SOAP 界面。我可以访问登录服务 ( https://api.textbroker.com/Budget/loginService.php?wsdl ) just fine, but when I try to access Budget Check Service ( https://api.textbroker.com/Budget/budgetCheckService.php?wsdl ),我收到以下错误消息:

suds.TypeNotFound: Type not found: '(Struct, http://www.w3.org/2001/XMLSchema, )'

据我阅读其他类似问题的理解,我需要使用 ImportDoctor 来解决这个问题。我尝试了以下方法:

    class BaseService:
        password = None
        wsdl = None
        client = None

        def __init__(self):
            imp = Import('http://www.w3.org/2001/XMLSchema')
            imp.filter.add("urn:loginService")
            self.client = Client(self.wsdl, doctor=ImportDoctor(imp), cache=None)

但不幸的是,我仍然收到相同的错误消息。我几乎可以肯定我需要使用 ImportDoctor 来解决这个问题,我只是做错了。

根据这个答案:SOAP suds and the dreaded schema Type Not Found error 您可能需要将特定位置添加到 Import()

imp = Import('http://www.w3.org/2001/XMLSchema',
              location='http://www.w3.org/2001/XMLSchema.xsd')