Porting a pearlescent application to python

I'm trying to port my SOAP communication application in Perl to the Python equivalent at the moment, but can't seem to get past this error it urllib2

throws through suds

. My working soap perl script:

use myStub;
$ENV{HTTPS_PKCS12_FILE} = '/path/to/certificate';
$ENV{HTTPS_PKCS12_PASSWORD} = 'password';
my $client = new myStub;
my $output = $client->foo('test', 'something');
print $output

      

where myStub

-.pm created stubmaker.pl

as part of SOAP::Lite

.

and I installed my python script like this:

from suds.client import Client
import os

os.environ['HTTPS_PKCS12_FILE'] = '/path/to/certificate'
os.environ['HTTPS_PKCS12_PASSWORD'] = 'password'
client = Client('file:WSDL')
output = client.service.foo('test', 'something')
print output

      

which gives me:

File "test.py", line 12, in <module>
    output = client.service.foo('test', 'something')
  File "/usr/lib/python2.6/site-packages/suds/client.py", line 542, in __call__
    return client.invoke(args, kwargs)
  File "/usr/lib/python2.6/site-packages/suds/client.py", line 602, in invoke
    result = self.send(soapenv)
  File "/usr/lib/python2.6/site-packages/suds/client.py", line 643, in send
    reply = transport.send(request)
  File "/usr/lib/python2.6/site-packages/suds/transport/https.py", line 64, in send
    return  HttpTransport.send(self, request)
  File "/usr/lib/python2.6/site-packages/suds/transport/http.py", line 77, in send
    fp = self.u2open(u2request)
  File "/usr/lib/python2.6/site-packages/suds/transport/http.py", line 118, in u2open
    return url.open(u2request, timeout=tm)
  File "/usr/lib64/python2.6/urllib2.py", line 391, in open
    response = self._open(req, data)
  File "/usr/lib64/python2.6/urllib2.py", line 409, in _open
    '_open', req)
  File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 1198, in https_open
    return self.do_open(httplib.HTTPSConnection, req)
  File "/usr/lib64/python2.6/urllib2.py", line 1165, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno 8] _ssl.c:490: EOF occurred in violation of protocol>

      

The client suds

is created well and if I print it out I get a list of expected methods, etc.

+3


source to share


1 answer


It seems, urllib2

can not contact the server. I doubt it urllib2

pays attention to environment variables HTTPS_PKCS12_*

. I assume they are specific to the Perl library you were using, or to Perl itself. urllib2

does not perform SSL certificate validation at all if you want to be better off using pycurl .

These two questions may point you in the right direction:



+5


source







All Articles