使用 suds 为 SOAP 编写 python 客户端

发布于 2024-08-05 17:20:24 字数 568 浏览 3 评论 0原文

我想将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

谈情不如逗狗 2024-08-12 17:20:24

当手动构造 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 as suds does. You have to patch suds, probably suds.transport.HttpTransport.open() method or suds.transport.Request class.

音盲 2024-08-12 17:20:24

我遇到了同样的错误,然后切换到使用本地 WSDL 文件,这有效:

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

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')
昔梦 2024-08-12 17:20:24

您应该在 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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文