2014-10-20 102 views
0

我有一個運行在Windows 7盒子上的ASP.NET webservice。我有兩個Linux框(Ubuntu 12.04),我試圖使用Python 2.7.3和Suds 0.4來訪問web服務。我試圖執行腳本如下:Python suds錯誤「NoneType」對象沒有屬性'promotePrefixes'「

from suds import client 
from suds.transport.https import WindowsHttpAuthenticated 
url = "https://webserver.mydomain.com/webservice/services.asmx?WSDL" 
ntlm = WindowsHttpAuthenticated(username = "user", password = "pwd") 
c = client.Client(url, transport = ntlm) 
resp = c.service.GetData() 

在我的Linux機器之一,該代碼執行完美,resp將包含從Web服務返回預期的數據。而Linux中,我得到了以下錯誤消息:

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/var/www/dev/local/lib/python2.7/site-packages/suds/client.py", line 542, in __call__ 
    return client.invoke(args, kwargs) 
    File "/var/www/dev/local/lib/python2.7/site-packages/suds/client.py", line 602, in invoke 
    result = self.send(soapenv) 
    File "/var/www/dev/local/lib/python2.7/site-packages/suds/client.py", line 643, in send 
    result = self.succeeded(binding, reply.message) 
    File "/var/www/dev/local/lib/python2.7/site-packages/suds/client.py", line 678, in succeeded 
    reply, result = binding.get_reply(self.method, reply) 
    File "/var/www/dev/local/lib/python2.7/site-packages/suds/bindings/binding.py", line 149, in get_reply 
    soapenv.promotePrefixes() 
AttributeError: 'NoneType' object has no attribute 'promotePrefixes' 

我需要什麼設置的一些想法,等可能會導致在兩臺機器之間的這種行爲差異。提前致謝!

+0

嘗試suds-jurko,看看錯誤是否仍然存在:http://pypi.python.org/pypi/suds-jurko – 2014-10-20 19:44:41

+0

@SimeonVisser - 試過泡沫-0.4,並得到了同樣的錯誤。我也在Windows 7上試過,並且也出現了相同的錯誤。但是,感謝這個想法。 – 2014-10-20 21:38:49

+0

此頁面幫助:https://bitbucket.org/jurko/suds/issue/50/error-unmarshalling-reply-promoteprefixes?它可能是一個格式錯誤的WSDL文件。 – 2014-10-20 22:55:17

回答

7

我添加了行來輸出額外的日誌信息,發現這個問題與拋出的Python錯誤無關,而是由於Web服務拒絕我的連接。下面是我添加到發佈的問題腳本行:

import logging 
logging.basicConfig(level=logging.INFO) 
logging.getLogger('suds.client').setLevel(logging.DEBUG) 

有了這些行補充說,我的劇本則產生以下輸出(部分):

<body> 
<div id="header"><h1>Server Error</h1></div> 
<div id="content"> 
<div class="content-container"><fieldset> 
    <h2>403 - Forbidden: Access is denied.</h2> 
    <h3>You do not have permission to view this directory or page using the credentials that you supplied.</h3> 
</fieldset></div> 
</div> 
</body> 

在這裏,我轉移我的注意力從客戶端到服務器,並能夠快速識別問題(這與我原來的問題無關!)。

相關問題