asmaier
asmaier

Reputation: 11746

Writing python client for SOAP with suds

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!

Upvotes: 1

Views: 6138

Answers (3)

hansaplast
hansaplast

Reputation: 11573

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

Upvotes: 3

Denis Otkidach
Denis Otkidach

Reputation: 33180

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.

Upvotes: 3

dalloliogm
dalloliogm

Reputation: 8940

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

Upvotes: 0

Related Questions