Python 泡沫错误 "' NoneType' 对象没有属性 'promotePrefixes'“

标签 python web-services soap ntlm suds

我有一个在 Windows 7 机器上运行的 ASP.NET 网络服务。我有两个 Linux 机器(Ubuntu 12.04),我试图使用 Python 2.7.3 和 Suds 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'

我需要一些关于哪些设置等可能导致两台机器之间的行为差​​异的想法。提前致谢!

最佳答案

我添加了一些行来输出额外的日志信息,发现问题与抛出的 Python 错误无关,而是由于网络服务拒绝了我的连接。以下是我添加到问题中发布的脚本中的行:

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 泡沫错误 "' NoneType' 对象没有属性 'promotePrefixes'“,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26473513/

相关文章:

php - appcfg.py 命令不断返回使用 : appcfg. py [options] <actions>

python - 有谁知道 FMPP 的 Python 等价物?

javascript - ASP.NET 按钮,仅当 OnClientClick 返回 true 时才执行 OnClick

java - 我怎样才能让多线程应用程序分布在java中?

.net - 错误 400(错误请求): maxReceivedMessageSize not taken into account for my WCF service

c# - 为什么 WCF 在遇到 302 响应时无法调用 SOAP 服务?

python - PyInstaller 中的 Kivy Garden - 试图跟踪导入时卡住了

python - 确定 a、b 中是否存在数字 n1、n2 和 c 中的 n3,使得 n1 + n2 = n3 [ftt,多项式乘法]

c# - .NET 2.0 Web 服务 WSDL 错误元素被忽略?

java - 如何为自动生成的 SOAP Web 服务请求提供相同的接口(interface)?