Python suds error “'NoneType' object has n

2019-08-02 20:19发布

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!

1条回答
看我几分像从前
2楼-- · 2019-08-02 21:01

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!).

查看更多
登录 后发表回答