2014-10-20 32 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> 

在这里,我转移我的注意力从客户端到服务器,并能够快速识别问题(这与我原来的问题无关!)。

相关问题