使用 suds 为 SOAP 编写 python 客户端
我想将 perl SOAP 客户端转换为 python SOAP 客户端。 Perl 客户端的初始化就像
$url = 'https://host:port/cgi-devel/Service.cgi';
$uri = 'https://host/Service';
my $soap = SOAP::Lite
-> uri($uri)
-> proxy($url);
我尝试在 python 2.4.2 中使用 suds 0.3.6 复制它
from suds.client import Client
url="https://host:port/cgi-devel/Service.cgi"
client=Client(url)
一样但是,当运行此 python 脚本时,我收到错误
suds.transport.TransportError: HTTP Error 411: Length Required
是否是因为 https 或者可能是什么问题? 任何帮助将不胜感激!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当手动构造 Request 对象时,
urllib2
模块不会像suds
那样自动添加 Content-Length(POST 方法所需)标头。您必须修补 suds,可能是suds.transport.HttpTransport.open()
方法或suds.transport.Request
类。urllib2
module doesn't add Content-Length (required for POST method) header automatically when Request object is constructed manually assuds
does. You have to patch suds, probablysuds.transport.HttpTransport.open()
method orsuds.transport.Request
class.我遇到了同样的错误,然后切换到使用本地 WSDL 文件,这有效:
I had the same error, then switched to using a local WSDL file, this worked:
您应该在 suds 的邮件列表中询问这个问题。该库正在开发中,是开源的,作者非常渴望获得用户的反馈。
您的代码看起来不错,这可能是 wsdl 本身或 suds 库的错误,因此我鼓励您直接询问作者(在与其他 wsdls 检查您的安装是否正确之后)。
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).