我目前正在尝试将我的 Perl SOAP 通信应用程序移植到 Python 等价物,但似乎无法克服urllib2
通过suds
. 我的工作 perl 肥皂脚本是:
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
作为 .pm 的一部分myStub
创建的 .pm 在哪里?stubmaker.pl
SOAP::Lite
我设置我的python脚本如下:
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
这给了我:
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>
客户端创建得suds
很好,如果我打印出来,我会列出预期的方法等。