SUDS python connection



我试图用python与suds构建一个web服务的客户端。我使用了教程在这个网站:http://www.jansipke.nl/python-soap-client-with-suds。它使用我自己编写的web服务和WSDL,但不使用我得到的WSDL文件。wsdl文件在soapUI中工作,我可以发送请求并获得答案。所以问题是,我认为,suds是如何解析wsdl文件。我得到以下错误:

urllib2.URLError: <urlopen error [Errno -2] Name or service not known>

有什么办法解决这个问题吗?如果你需要更多的信息,请询问。谢谢你!

您给我们的错误似乎暗示您用于访问WSDL的URL不正确。你能给我们多展示一下你的代码吗?例如,客户端安装和WSDL的url。这可能会让其他人真正帮助你。

奥丽

# 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))

相关内容

最新更新