C# python3-zeep-soap-x27;命名空间xxx中的元素值不能将子内容反序列化为对象';
我在wsdl上有这个方法C# python3-zeep-soap-x27;命名空间xxx中的元素值不能将子内容反序列化为对象';,c#,python,xml,soap,C#,Python,Xml,Soap,我在wsdl上有这个方法 <xs:element name="createDocument"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="repositoryId" nillable="true" type="xs:string"/> <xs:element xmlns:q7="http://schemas.microsoft.com/2003/10/Seri
<xs:element name="createDocument">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="repositoryId" nillable="true" type="xs:string"/>
<xs:element xmlns:q7="http://schemas.microsoft.com/2003/10/Serialization/Arrays" minOccurs="0" name="properties" nillable="true" type="q7:ArrayOfKeyValueOfstringanyType"/>
<xs:element xmlns:q8="http://docs.oasis-open.org/ns/cmis/core/200908/" minOccurs="0" name="contentStream" nillable="true" type="q8:ContentStream"/>
<xs:element xmlns:q9="http://docs.oasis-open.org/ns/cmis/core/200908/" minOccurs="0" name="versioningState" type="q9:VersioningState"/>
<xs:element xmlns:q10="http://schemas.microsoft.com/2003/10/Serialization/Arrays" minOccurs="0" name="policies" nillable="true" type="q10:ArrayOfstring"/>
</xs:sequence>
</xs:complexType>
</xs:element>
但我有个例外
zeep.exceptions.Fault:格式化程序在运行时引发异常
正在尝试反序列化消息:尝试
反序列化参数。这个
InnerException消息是命名空间中的“元素值”
不可能有
要反序列化为对象的子内容。请使用XmlNode[]
要反序列化此XML模式。“。有关详细信息,请参见InnerException
更多细节
有什么建议吗?要解决这个问题,
我将库从zeep更改为,因为它允许在通过插件发送之前更改xml消息
我还尝试使用医生添加名称空间,但没有成功
这是密码
类修复类型(MessagePlugin):
已封送的def(自身、上下文):
context.envelope.getChild('Body').getChild('createDocument').getChild('properties')[0].getChild('Value').set('xmlns:c','http://www.w3.org/2001/XMLSchema')
context.envelope.getChild('Body').getChild('createDocument').getChild('properties')[0].getChild('Value').set('i:type','c:boolean'))
context.envelope.getChild('Body').getChild('createDocument').getChild('properties')[1].getChild('Value').set('xmlns:c','http://www.w3.org/2001/XMLSchema')
context.envelope.getChild('Body').getChild('createDocument').getChild('properties')[1].getChild('Value').set('i:type','c:boolean'))
context.envelope.getChild('Body').getChild('createDocument').getChild('properties').set('xmlns:i','http://www.w3.org/2001/XMLSchema-instance')
客户端=客户端(“,用户名=”,密码=”,插件=[FixTypes()])
要解决此问题,
我将库从zeep更改为,因为它允许在通过插件发送之前更改xml消息
我还尝试使用医生添加名称空间,但没有成功
这是密码
类修复类型(MessagePlugin):
已封送的def(自身、上下文):
context.envelope.getChild('Body').getChild('createDocument').getChild('properties')[0].getChild('Value').set('xmlns:c','http://www.w3.org/2001/XMLSchema')
context.envelope.getChild('Body').getChild('createDocument').getChild('properties')[0].getChild('Value').set('i:type','c:boolean'))
context.envelope.getChild('Body').getChild('createDocument').getChild('properties')[1].getChild('Value').set('xmlns:c','http://www.w3.org/2001/XMLSchema')
context.envelope.getChild('Body').getChild('createDocument').getChild('properties')[1].getChild('Value').set('i:type','c:boolean'))
context.envelope.getChild('Body').getChild('createDocument').getChild('properties').set('xmlns:i','http://www.w3.org/2001/XMLSchema-instance')
客户端=客户端(“,用户名=”,密码=”,插件=[FixTypes()])
我面临同样的问题,但不想离开Zeep
经过大量调试并将Zeep生成的XML与Web服务所需的XML进行比较后,我想到Zeep没有在生成的XML中指定数据类型“boolean”
这可以通过指定“值”:xsd.AnyObject(xsd.Boolean(),False)
作为PdV\u-VerificaFirmaFiles
的值来完成
所以,最后,这段代码对我起了作用:
from zeep import xsd
....
soap_response = soap_client.service.createDocument(
repositoryId=1,
properties=[{
'KeyValueOfstringanyType': {'Key': 'PdV_VerificaFirmaFiles',
'Value': xsd.AnyObject(xsd.Boolean(), False)}
}],
contentStream={
'filename': 'PdVDocumento.zip',
'length': zip_size,
'stream': zip_file_contents
}
)
我面临同样的问题,但不想离开泽普 经过大量调试并将Zeep生成的XML与Web服务所需的XML进行比较后,我想到Zeep没有在生成的XML中指定数据类型“boolean” 这可以通过指定
“值”:xsd.AnyObject(xsd.Boolean(),False)
作为PdV\u-VerificaFirmaFiles
的值来完成
所以,最后,这段代码对我起了作用:
from zeep import xsd
....
soap_response = soap_client.service.createDocument(
repositoryId=1,
properties=[{
'KeyValueOfstringanyType': {'Key': 'PdV_VerificaFirmaFiles',
'Value': xsd.AnyObject(xsd.Boolean(), False)}
}],
contentStream={
'filename': 'PdVDocumento.zip',
'length': zip_size,
'stream': zip_file_contents
}
)