【发布时间】:2020-01-11 20:10:04
【问题描述】:
我很难反序列化下面的肥皂响应。 我假设它是因为多个命名空间或者可能是因为复杂类型(序列化数组)
Soapformatter 抛出一个对象引用异常,其他更多手动反序列化返回一个空对象。在这一点上,我只能假设我没有正确标记我的对象。构建下面的 BatchResponse 对象以便它可以从此响应反序列化的正确方法是什么?
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">https://example.com/operations/fetch/BatchResponse</a:Action>
</s:Header>
<s:Body>
<BatchResponse xmlns="https://example.com/operations">
<BatchResult xmlns:b="https://example.com/responses" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<b:FailureMessages xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays" i:nil="true" />
<b:FailureType i:nil="true" />
<b:ProcessedSuccessfully>true</b:ProcessedSuccessfully>
<b:SessionId>1961810</b:SessionId>
<b:TotalPages>38</b:TotalPages>
</BatchResult>
</BatchResponse>
</s:Body>
</s:Envelope>
还假设 Soapformatter 继续抛出异常 - “xpath”到 BatchResponse 对象以便我可以提取和反序列化的正确方法是什么?
谢谢
【问题讨论】:
-
下面的解决方案有效,但当命名空间包含两个句点和一个破折号时 - 例如 example.test-site.com - 不知道为什么!
标签: c# xml soap xml-deserialization soapformatter