views:

886

answers:

3

Dear python programmers,

I want to convert a perl SOAP client into a python SOAP client. The perl client is initialized like

$url = 'https://host:port/cgi-devel/Service.cgi';
$uri = 'https://host/Service';

my $soap = SOAP::Lite 
    -> uri($uri)
    -> proxy($url);

I tried to replicate this in python 2.4.2 with suds 0.3.6 doing

from suds.client import Client

url="https://host:port/cgi-devel/Service.cgi" 
client=Client(url)

However when running this python script I get the error

suds.transport.TransportError: HTTP Error 411: Length Required

Is it because of https or what might be the problem? Any help would be greatly appreciated!

A: 

You should ask this in the suds's mailing list. This library is under development, is open source, and the authors are very keen to get feedback from the users.

Your code looks fine, this could be an error of the wsdl itself or of the suds library, therefore I encourage you to ask the author directly (after having checked with other wsdls that your installation is correct).

dalloliogm
+2  A: 

urllib2 module doesn't add Content-Length (required for POST method) header automatically when Request object is constructed manually as suds does. You have to patch suds, probably suds.transport.HttpTransport.open() method or suds.transport.Request class.

Denis Otkidach
Based on your tips I actually managed to get rid of the error message. But I still could not connect to the server. Later it became clear that, instead of SOAP, I could use another very simple method to connect to the server in question. So I'm not using SOAP anymore, therefore the question has become obsolete for me.
asmaier
A: 

I had the same error, then switched to using a local WSDL file, this worked:

import suds
wsdl = 'file:///tmp/my.wsdl'
client = suds.client.Client(wsdl, username='lbuser', password='lbpass', location='https://path.to.our.loadbalancer:9090/soap')
Philipp Keller