【发布时间】:2018-10-16 10:30:10
【问题描述】:
使用zeep时,如下代码:
string_type = client.get_type("xsd:string")
string_expression = string_type("my string value")
结果如下:
<ns1:Value>my string value</ns1:Value>
SOAP 服务器上的序列化程序所期望的实际上是这样的:
<ns1:Value xsi:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">my string value</ns1:Value>
这种差异导致 SOAP 服务器抛出异常:
zeep.exceptions.Fault:格式化程序在尝试时抛出异常 反序列化消息:尝试 反序列化参数http://Services.IPWS/。这 InnerException 消息是“来自命名空间的元素值” http://schemas.datacontract.org/ 不能将子内容反序列化为对象。请用 XmlNode[] 来反序列化这种 XML 模式。请参见 InnerException 了解更多详情。
如何让 zeep 保留 XML 标记中的类型声明?
【问题讨论】: