【问题标题】:Python suds error "'NoneType' object has no attribute 'promotePrefixes'"Python suds 错误“'NoneType' 对象没有属性 'promotePrefixes'”
【发布时间】:2014-10-20 19:34:20
【问题描述】:

我有一个在 Windows 7 机器上运行的 ASP.NET 网络服务。我有两个 Linux 机器(Ubuntu 12.04),我正在尝试使用 Python 2.7.3 和 Suds 0.4 来访问 Web 服务。我正在尝试执行的脚本如下:

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'

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

【问题讨论】:

  • 试试 suds-jurko 看看 bug 是否仍然存在:pypi.python.org/pypi/suds-jurko
  • @SimeonVisser - 尝试 suds-jurko 0.6 并得到同样的错误。我也在 Windows 7 机器上尝试过,在那里也遇到了同样的错误。但是感谢您的想法。
  • 此页面是否有帮助:bitbucket.org/jurko/suds/issue/50/… ?它可能是格式错误的 WSDL 文件。
  • 链接听起来很有希望,但没有骰子。客户端和服务器都使用 SOAP 1.1。强制使用 SOAP 1.2 并得到相同的错误。改变一个或另一个,我得到“soap:VersionMismatch”异常,正如预期的那样。

标签: python web-services soap ntlm suds


【解决方案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>

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-02
    • 1970-01-01
    • 2014-06-04
    • 1970-01-01
    相关资源
    最近更新 更多