如何在 python 中使用 wsdl url [英] How can I consume wsdl url in python
问题描述
我想使用来自 WSDL url 的数据,我不知道在 python 中我该怎么做.
I want to consume data from WSDL url, I don't know how would I do in python.
谁能帮我举个例子
这里是 WSDL 链接供参考:http://43.242.214.173/cwplservice/cwplonline.svc?wsdl
here is the WSDL link for reference : http://43.242.214.173/cwplservice/cwplonline.svc?wsdl
这是我尝试过的代码片段.
Here is code snippet which I have tried.
from suds.client import Client
from suds.xsd.doctor import Import, ImportDoctor
url = 'http://43.242.214.173/cwplservice/cwplonline.svc?wsdl'
imp = Import('http://212.235.42.50/WebService/service.php?class=masterPricer', location='https://www.w3.org/2001/XMLSchema.xsd')
imp.filter.add('http://www.w3.org/2001/XMLSchema')
client = Client(url, doctor=ImportDoctor(imp))
print client
当我运行代码时出现以下错误suds.TypeNotFound:找不到类型:'(架构,http://www.w3.org/2001/XMLSchema, )'
when I run the code I am getting following error as suds.TypeNotFound: Type not found: '(schema, http://www.w3.org/2001/XMLSchema, )'
推荐答案
您是否研究过 PySimpleSOAP?我用过它,它非常适合进行 SOAP 调用和解析小型 XML 响应.对于非常大的 XML 消息响应,它在我身上崩溃了,最终使用 xml.etree.ElemenTree 编写了我自己的 XML 处理程序.
Did you looked into PySimpleSOAP? I've used it, it is pretty good for making SOAP calls and parsing small size XML responses. For very large XML message responses it has crashed on me, ended up writing my own XML handler using xml.etree.ElemenTree.
https://pypi.python.org/pypi/PySimpleSOAP/1.02b
这篇关于如何在 python 中使用 wsdl url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!