Answer:
A .NET serialization system supports backward-compatibility on custom data types naturally. However, sometimes we also need forward-compatibility for data types used in a WCF service.ExtensionDataObject property is used to achieve the Forward compatible in WCF.
Suppose that you have a service that exchanges some custom data types between clients. If one side updates the custom data type (adds some fields or properties) or uses a newer version, it is important to make sure that the other side can still work correctly with the updated data type instances without using the updated version of data.
Let see how can we achieve this in WCF.
1.First we need to make our Custom Data type to implement the IExtensibleDataObject interface.
[DataContract]
public class Employee: IExtensibleDataObject
{
[DataMember]
public string Name{ get; set; } [DataMember]
public string Address{ get; set; }
public ExtensionDataObject ExtensionData
{
get;
set;
}
}
2. Next we need to make sure that we haven't enabled the IgnoreExtensionDataObject property on ServiceBehaviorAttribute applied on your WCF service .This property is disabled by default.
Asked In: Many Interviews |
Alert Moderator