简体   繁体   中英

WCF DataContract mismatch

We have this middle tier (WCF) deployed in a IIS. Sometime, DataContact changes property data type. ie (StudentID)

From:

[DataContact]
public class Student
{
    public int StudentID { get; set; }
    public string Name { get; set; }
}

To:

[DataContact]
public class Student
{
    public string StudentID { get; set; }
    public string Name { get; set; }
}

Question: Is there a way to tell the client or send a message (error) to client that the DataContract changed?

WCF support versioning capabilities.

However, when you Modify return value types then An exception will occur if the return value from the service cannot be converted to the expected data type in the client version of the operation signature.

The important distinction to understand is that there are certain changes which are breaking and other non-breaking changes. For eg If you add a new method to the WCF Service, then it's a Non-Breaking change, but if you remove the method it's a breaking change for the clients.

For Additional reading, read here at msdn

During the design for WCF Services, it is recommended to Services version tolerant, so that client on different version can work with the Service. Also, you would need to communicate the changes using email/document etc. I do not believe there is out of box support for Managing notifications. It appears to be an administrative work for which you can otherwise do using other communication medium like emails etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM