作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我必须用 suds 和 Python 做 soap 请求
<soap:Body>
<registerOrder>
<order merchantOrderNumber="" description="" amount="" currency="" language="" xmlns="">
<returnUrl>http://mysafety.com</returnUrl>
</order>
</registerOrder>
</soap:Body>
如何在registerOrder中添加一个属性?
最佳答案
一个更加动态的 MessagePlugin 版本是:
from suds.sax.attribute import Attribute
from suds.plugin import MessagePlugin
class _AttributePlugin(MessagePlugin):
"""
Suds plug-in extending the method call with arbitrary attributes.
"""
def __init__(self, **kwargs):
self.kwargs = kwargs
def marshalled(self, context):
method = context.envelope.getChild('Body')[0]
for key, item in self.kwargs.iteritems():
method.attributes.append(Attribute(key, item))
用法:
client = Client(url)
# method 1
client.options.plugins = [_AttributePlugin(foo='bar')]
response = client.service.method1()
client.options.plugins = []
# method 2
response = client.service.method2()
关于python - 在泡沫中添加一个属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5588403/
我正在尝试在 python Google App Engine 应用程序中使用 suds。这是回溯: client = Client(url) File "/base/data/home/apps
我在 Apache 下使用 ssl 提供肥皂服务,没有 ssl 的 suds 效果更好。 我有客户端证书(my.crt 和 user.p12 文件)。 我需要如何配置 suds 客户端以使其与 htt
我正在使用 django 开发一个网络,它处理 wsdl。我有一个处理它的示例代码,但它是用 PHP 编写的,我想为我的 django 将它转换为 python。这是 PHP 文件 ... SOAP
我有以下使用 Suds 的简单 python 测试脚本调用 SOAP 网络服务(该服务是用 ASP.net 编写的): from suds.client import Client url = 'ht
我正在创建一个请求,以在 Django 中使用 SUDS (4.0) 来使用 Web 服务。 然而,Suds 没有放置正确的命名空间。 我得到的肥皂信封:
我是一名优秀的程序员,十分优秀!