我正在尝试使用suds在python中为with服务构建一个客户端。我在这个网站上使用了教程:http://www.jansipke.nl/python-soap-client-with-suds。它可以使用我自己编写的Webservice和WSDL,但不能使用我得到的wsdl文件。wsdl文件在soapUI中工作,我可以发送请求并获得答案。因此,我认为问题在于suds是如何解析wsdl文件的。我得到以下错误:
urllib2.URLError: <urlopen error [Errno -2] Name or service not known>有什么办法解决这个问题吗?如果您需要更多信息,请提问。谢谢!
发布于 2011-11-01 18:31:30
您给我们的错误似乎暗示您用来访问WSDL的URL不正确。你能给我们展示更多你的代码吗?例如客户端实例和指向WSDL的url。这可能会让其他人真正帮助你。
奥利
发布于 2017-01-30 18:24:50
# SUDS is primarily built for Python 2.6/7 (Lightweight SOAP client)
# SUDS does not work properly with other version, absolutely no support for 3.x
# Test your code with Python 2.7.12 (I am using)
from suds.client import Client
from suds.sax.text import Raw
# Use your tested URL same format with '?wsdl', Check once in SOAP-UI, below is dummy
# Make sure to use same Method name in below function 'client.service.MethodName'
url = 'http://localhost:8080/your/path/MethodName?wsdl'
#Use your Request XML, below is dummy, format xml=Raw('xml_text')
xml = Raw('<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:diag=" </soapenv:Body></soapenv:Envelope>')
def GetResCode(url, xml):
client = Client(url)
xml_response = (client.service.MethodName(__inject={'msg':xml}))
return xml_response
print(GetResCode(url,xml))https://stackoverflow.com/questions/7917609
复制相似问题