Error in python webservice client using suds

2019-09-10 06:17发布

问题:

Im using python 2.7 and suds 0.4 in windows and linux and in both cases I get the same error when calling a method of a web service:

Traceback (most recent call last):
File "wsclient.py", line 23, in <module>
client.service.Echo()
File "build\bdist.win32\egg\suds\client.py", line 542, in __call__
File "build\bdist.win32\egg\suds\client.py", line 602, in invoke
File "build\bdist.win32\egg\suds\client.py", line 643, in send
File "build\bdist.win32\egg\suds\client.py", line 678, in succeeded
File "build\bdist.win32\egg\suds\bindings\binding.py", line 149, in get_reply
AttributeError: 'NoneType' object has no attribute 'promotePrefixes'

My code is really simple:

import suds.bindings
suds.bindings.binding.envns = ('SOAP-ENV', 'http://www.w3.org/2003/05/soap-envelope')

from suds.client import Client

url = 'http://servicios.publipayments.com/ServicioDW.svc?wsdl'
client = Client(url)
print client
client.service.Echo()

As you can see I already did what the author of suds suggest here and also did the logging in here. But the result is the same.

Any ideas will be appreciated.

Regards.

回答1:

My understanding about web services was not good enough and the service implementation is using http for exposing the wsdl AND https for the service endpoint.

So after a helpful hint of the service author I declared the client as:

client = Client('http://someUrl?wsdl', 
                location='https://someUrl/Service.svc')

And that solved the problem. There was nothing bad with suds.