Python的泡沫错误“‘NoneType’对象有没有属性‘promotePrefixes’”(Py

2019-10-21 04:27发布

我有一个Windows 7机器上运行的Web服务ASP.NET。 我有两个Linux系统(Ubuntu的12.04),我试图打从web服务,使用Python 2.7.3和肥皂水0.4。 我试图执行的脚本如下:

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'

我需要什么设置等一些想法可能会导致在两台机器之间的这种行为差异。 提前致谢!

Answer 1:

我添加的行输出额外的日志记录信息,发现问题无关,与抛出的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>

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



文章来源: Python suds error “'NoneType' object has no attribute 'promotePrefixes'”