我正在尝试为 Textbroker API 创建 Python 客户端,但无法访问其 SOAP 接口(interface)。我可以正常访问登录服务 (https://api.textbroker.com/Budget/loginService.php?wsdl),但是当我尝试访问预算检查服务 (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')
