Python suds 错误“'NoneType' 对象没有属性 'promotePrefixes'" [英] Python suds error "'NoneType' object has no attribute 'promotePrefixes'"

查看:225
本文介绍了Python suds 错误“'NoneType' 对象没有属性 'promotePrefixes'"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

from suds 导入客户端从 suds.transport.https 导入 WindowsHttpAuthenticatedurl = "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 机器上,我收到以下错误消息:

回溯(最近一次调用最后一次):文件<stdin>",第 1 行,在 <module> 中文件/var/www/dev/local/lib/python2.7/site-packages/suds/client.py",第 542 行,在 __call__返回 client.invoke(args, kwargs)调用中的文件/var/www/dev/local/lib/python2.7/site-packages/suds/client.py",第 602 行结果 = self.send(soapenv)文件/var/www/dev/local/lib/python2.7/site-packages/suds/client.py",第 643 行,发送结果 = self.succeeded(绑定,reply.message)文件/var/www/dev/local/lib/python2.7/site-packages/suds/client.py",第678行,成功回复,结果 = binding.get_reply(self.method,reply)文件/var/www/dev/local/lib/python2.7/site-packages/suds/bindings/binding.py",第 149 行,在 get_reply 中soapenv.promotePrefixes()AttributeError: 'NoneType' 对象没有属性 'promotePrefixes'

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

解决方案

我加了几行输出额外的日志信息,发现问题与抛出的Python错误无关,而是web服务造成的拒绝我的连接.以下是我添加到问题中发布的脚本中的行:

导入日志logging.basicConfig(level=logging.INFO)logging.getLogger('suds.client').setLevel(logging.DEBUG)

添加这些行后,我的脚本生成了以下输出(部分):

<div id="header"><h1>服务器错误</h1></div><div id="内容"><div class="content-container"><fieldset><h2>403 - 禁止:访问被拒绝.</h2><h3>您无权使用您提供的凭据查看此目录或页面.</h3></fieldset></div>

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

I have an ASP.NET webservice running on a Windows 7 box. I have two Linux boxes (Ubuntu 12.04) that I'm trying to hit the webservice from, using Python 2.7.3 and Suds 0.4. The script I'm trying to execute is as follows:

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()

On one of my Linux boxes, this code executes perfectly and resp will contain the expected data returned from the web service. On the other Linux box, I get the following error message:

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'

I need some ideas on what settings, etc. could be causing this difference in behavior between the two machines. Thanks in advance!

解决方案

I added lines to output additional logging information, and found that the problem had nothing to do with the Python error being thrown, but was instead due to the web service rejecting my connection. Here are the lines I added to the script posted in the question:

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

With these lines added, my script then produced the following output (partial):

<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>

From here I shifted my focus from the clients to the server, and was able to quickly identify the problem (which has nothing to do with my original question!).

这篇关于Python suds 错误“'NoneType' 对象没有属性 'promotePrefixes'"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆