[英]Python SUDS - Can't generate the proper SOAP request
I am having a problem trying to generate the right soap request using SUDS.我在尝试使用 SUDS 生成正确的 soap 请求时遇到问题。 For a certain xml element, i need to specify the attribute using the namespace:对于某个 xml 元素,我需要使用命名空间指定属性:
ns0:type
The original specification is:原始规范是:
(ParameterType){
Name =
(NameType){
value = None
_required = ""
}
Description = None
Value =
(ValueType){
Text = None
XmlDoc = None
_type = ""
}
}
So I get this xml:所以我得到这个 xml:
<ns0:parameters>
<ns0:Input>
<ns0:Parameter>
<ns0:Name required="true">Param</ns0:Name>
<ns0:Value type="xs:Text">
<ns0:Text>1</ns0:Text>
</ns0:Value>
</ns0:Parameter>
</ns0:Input>
</ns0:parameters>
What I need to get it this one:我需要什么才能得到它:
<ns0:parameters>
<ns0:Input>
<ns0:Parameter>
<ns0:Name required="true">Param</ns0:Name>
<ns0:Value ns0:type="xs:Text">
<ns0:Text>1</ns0:Text>
</ns0:Value>
</ns0:Parameter>
</ns0:Input>
</ns0:parameters>
I tried using plugins, but I guess It doesn't like the ":" char.我尝试使用插件,但我猜它不喜欢“:”字符。 Here is the code:这是代码:
class MyPlugin(MessagePlugin):
def marshalled(self, context):
foo = context.envelope.getChild('Body').getChild('ns0:executeProcess').getChild('ns0:parameters').getChild('ns0:Input').getChild('ns0:Parameter').getChild('ns0:Value')
foo.attributes.append(Attribute("ns0:type", "Text"))
Any ideas about how can I achieve this?关于如何实现这一目标的任何想法?
More info: suds 0.4.1 - python 2.4更多信息:泡沫 0.4.1 - python 2.4
I found the proper plugin use:我找到了正确的插件用法:
class MyPlugin(MessagePlugin):
def marshalled(self, context):
inputElement = context.envelope.getChild('Body').getChild('ns0:executeProcess').getChild('ns0:parameters').getChild('ns0:Input')
parametrosElements = inputElement.getChildren()
for i in range( len( parametrosElements ) ):
valueElement = parametrosElements[i].getChild('ns0:Value')
valueElement.attributes.append(Attribute("ns0:type", "Text" ))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.