2011-10-27 87 views
0

即時嘗試建立一個客戶端在python與泡沫web服務。我在本網站上使用了教程 :http://www.jansipke.nl/python-soap-client-with-suds。它與我自己編寫的Web服務和WSDL一起工作,但與我所獲得的wsdl文件無關。 wsdl文件在soapUI中工作,我可以發送請求並獲得答案。所以問題是,我認爲,suds是如何解析wsdl文件的。我得到以下錯誤:SUDS python連接

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

任何想法如何解決這個問題?如果您需要更多信息,請詢問。謝謝!

回答

2

您給我們的錯誤似乎意味着您用於訪問WSDL的URL不正確。你能告訴我們更多你的代碼嗎?例如客戶端實例和WSDL的url。這可能會讓別人真的幫助你。

奧利

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