Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Suds-python中覆盖Soap信封_Python_Xml_Soap_Suds_Envelope - Fatal编程技术网

在Suds-python中覆盖Soap信封

在Suds-python中覆盖Soap信封,python,xml,soap,suds,envelope,Python,Xml,Soap,Suds,Envelope,我有一个照相机,我正试图用肥皂水把它连接起来。我尝试发送原始xml,发现唯一阻止xml泡沫工作的是不正确的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_n

我有一个照相机,我正试图用肥皂水把它连接起来。我尝试发送原始xml,发现唯一阻止xml泡沫工作的是不正确的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绑定中的。有没有办法在肥皂水中覆盖这个


感谢您的帮助。

我成功地实现了这一点,soap信封被硬编码到
bindings.py
中,存储在您的站点包中安装的
suds.egg
中。我将SOAP信封地址更改为
http://www.w3.org/2003/05/soap-envelope
。这与我的相机兼容。我找不到在suds中覆盖此信封的命令,因此我将其硬编码到bindings.py中


感谢您的帮助

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


另外,您正在使用哪些版本的Python和suds?

我通过手动覆盖
绑定
模块中的
suds.binding.envns
变量来解决这个问题:

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

从现在开始,一切都很顺利(我的服务就是)

你会遇到什么类型的错误?你能详细说明并发布你的代码吗?关于如何将标题输入肥皂水,请查看我之前的问题。我将发布我的代码,因为我知道文档太少了。
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()])