WCF Disable Deserialization Order Sensitivity

后端 未结 4 587
说谎
说谎 2020-12-09 15:01

I have a recurring problem when passing Serialized objects between non-.NET Clients, and .NET WCF Services.

When WCF Deserializes objects, it is strictly dependant

4条回答
  •  醉酒成梦
    2020-12-09 15:42

    For me, the DataContractSerializer has been my savior with .NET Framework 4.0

    When referencing an old asmx web service, we had null values for all the fields that were "after" inserted new fields in the server wsdl. So whenever there were new fields added on server side, that was nullifying several values on client side. This was forcing us into updating our reference in our code to always stick to the server wsdl.

    I found two solutions to make our client tolerant to new fields in the xml stream:

    • Either use an old web reference in visual studio (old client code generator for compatibility)
    • Or use a WCF classic reference, but change the serializer in the svcmap file. ClientOptions -> Serializer = "DataContractSerializer" instead of "Auto". I found out that in our case, the "Auto" value was the same as "XmlSerializer" value.

提交回复
热议问题