【问题标题】:Writing python client for SOAP with suds使用 suds 为 SOAP 编写 python 客户端
【发布时间】:2009-09-25 11:36:23
【问题描述】:

我想将 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);

我试图用 suds 0.3.6 在 python 2.4.2 中复制它

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还是可能是什么问题? 任何帮助将不胜感激!

【问题讨论】:

  • 我前段时间在 suds 网页上开了一张关于这个问题的票(见fedorahosted.org/suds/ticket/259),但到目前为止没有得到任何回应。由于我不再在我的项目中使用 SOAP,所以这个问题对我来说已经过时了。

标签: python soap https suds


【解决方案1】:

urllib2 模块不会像suds 那样手动构造请求对象时自动添加 Content-Length(POST 方法所需)标头。您必须修补 suds,可能是 suds.transport.HttpTransport.open() 方法或 suds.transport.Request 类。

【讨论】:

  • 根据您的提示,我实际上设法摆脱了错误消息。但我仍然无法连接到服务器。后来很明显,除了 SOAP,我还可以使用另一种非常简单的方法连接到相关服务器。所以我不再使用 SOAP,因此这个问题对我来说已经过时了。
【解决方案2】:

我有同样的错误,然后切换到使用本地 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')

【讨论】:

    【解决方案3】:

    您应该在 suds 的邮件列表中提出这个问题。这个库正在开发中,是开源的,作者非常渴望得到用户的反馈。

    您的代码看起来不错,这可能是 wsdl 本身或 suds 库的错误,因此我鼓励您直接询问作者(在与其他 wsdl 确认您的安装正确之后)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多