【问题标题】:Webservice response with nullable doubles is not deserialized properly具有可空双精度的 Web 服务响应未正确反序列化
【发布时间】:2012-10-15 09:34:03
【问题描述】:

我正在从我们的一位合作伙伴那里调用网络服务。我调用它没有问题,我得到了一个结果。 响应具有可为空的双精度值。在提琴手中,我在响应的 XML 中看到这些双精度值具有值,但不知何故,这些字段不会反序列化到我的代理类,因为这些字段在那里的值为 null。

这是我得到的响应 xml 的摘要,不知何故 id27 中的值没有被序列化,但 id26 中的布尔值可以。为什么?

<extras soapenc:arrayType="ns2:Extra[16]" xsi:type="soapenc:Array">
    <extras href="#id1"/>
    <extras href="#id2"/>           
    ...
</extras>
...
<multiRef id="id1" soapenc:root="0" 
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
xsi:type="ns6:Extra" xmlns:ns6="http://model.bookingservice.app.traserv.com" 
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
    <assignments xsi:type="ns6:Assignment" xsi:nil="true"/>
    <category xsi:type="xsd:string">def_Surety</category>           
    ...
    <orderUnit xsi:type="xsd:string">Verblijf</orderUnit>
    <payAtLocation href="#id26"/>
    <price href="#id27"/>
    <priceNotes xsi:type="xsd:string" xsi:nil="true"/>
     ...
</multiRef>
...
<multiRef id="id26" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
xsi:type="xsd:boolean" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">true</multiRef>
<multiRef id="id27" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:double" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">345.0</multiRef>

【问题讨论】:

    标签: c# web-services serialization double nullable


    【解决方案1】:

    我发现 WCF 客户端和轴网络服务确实存在这些问题。 您可以在代理中解决它,这显然不是很好,因为您必须编辑生成的类。或者您可以更改 Web 服务,这也是一个问题,因为您无法始终控制该服务。

    不管怎样,我找到了关于它的这些项目: http://www.tomergabel.com/GettingWCFAndApacheAxisToBeFriendly.aspx

    Why won't .NET deserialize my primitive array from a web service?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多