繁体   English   中英

在Suds python中覆盖Soap Envelope

[英]Overwrite the Soap Envelope in Suds python

我有一个相机,我正试图连接它与泡沫。 我试图发送原始的xml,并发现阻止xml suds工作的唯一因素是不正确的Soap信封命名空间。

信封命名空间是:

xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"

我想把它重写为:

xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"

为了在python中添加命名空间,我尝试以下代码:

message = Element('Element_name').addPrefix(p='SOAP-ENC', u='www.w3.org/ENC')

但是当我将SOAP-ENV添加到命名空间时,它不会写入,因为它被硬编码到suds绑定中。 有没有办法在泡沫中覆盖这个?

谢谢你的帮助。

我通过手动覆盖bindings模块中的suds.binding.envns变量来解决它:

from suds.bindings import binding
binding.envns=('SOAP-ENV', 'http://www.w3.org/2003/05/soap-envelope')

从这里开始,一切顺利( 我的服务,即)

我设法让这个工作,soap信封被硬编码到bindings.py ,存储在你的site-packages中安装的suds.egg中。 我将SOAP信封地址更改为http://www.w3.org/2003/05/soap-envelope 这与我的相机兼容。 我无法在suds中找到覆盖此信封的命令,因此我将其硬编码到bindings.py中。

谢谢你的帮助

手动更新binding.py肯定不是正确的方法。 您应该能够利用ImportDoctor覆盖默认绑定。 在Suds网站上查看修复损坏模式的文档。

另外,你使用的是什么版本的Python和suds?

from suds.client import Client
from suds.plugin import MessagePlugin

WSDL_url = "my_url?wsdl"

class MyPlugin(MessagePlugin):
    def marshalled(self, context):
        #print(str(context.envelope))
        context.envelope.nsprefixes['SOAP-ENV']='myText'

client = Client(WSDL_url, plugins=[MyPlugin()])

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM