I have converted my web service to wcf service which has some datacontracts. As a best practice it is mentioned and advisable that the DataContracts should inherit from IExtensibleDataObject. I get the point that in case of addition or removal of datamembers, IExtensibleDataObject is helpful. But i am not able to get how will the clients access removed datamembers. Here is my code:
[ServiceContract(Namespace = "http://mycompany.com/2010/08/")] public class MyWebService { [OperationContract] public Employee Add(Employee emp) { // Some Processing } } [DataContract(Name = "Employee", Namespace = "http://mycompany.com/2010/08/")] public class Employee : IExtensibleDataObject { [DataMember] public string FirstName; [DataMember] public string LastName; public ExtensionDataObject ExtensionData { get; set; } }
Now in my next version of web service I made some changes to DataContract as
[DataContract(Name = "Employee", Namespace = "http://mycompany.com/2010/09/")] public class Employee : IExtensibleDataObject { [DataMember] public string FirstName; [DataMember] public string LastName; [DataMember(IsRequired = true)] public string MiddleName; public ExtensionDataObject ExtensionData { get; set; } }
However my client that is accessing my older version of web service is now getting error for not supplying the MiddleName field. I am still confused for the usage of IExtensionDataObject.
Please help.