Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mark deprecated fields in WCF contract

I have a wcf contract that works with client v1.

Now I'm working on service v2, and i want to mark some of the fields as deprecated, So client v1 will see and use them, and client v2 will ignore them.

Are there any best practices for this issue? Are there any existing attributes in WCF that i should use?

thanks.

like image 221
Adibe7 Avatar asked Mar 23 '11 11:03

Adibe7


1 Answers

You can decorate your old properties as [Obsolete] but the client will only see them if they use a DLL reference and not service/web reference (WSDL). [Obsolete] decoration will not be passed to the client that uses WSDL to generate the proxy.

In terms of WCF versioning, once you have published an interface, you cannot remove any methods or in terms of contract you should really not remove any properties. You can publish a new interface and create a separate DTO class if you want new clients to use them.

Ref: Obsolete Attribute.

like image 94
Aliostad Avatar answered Oct 20 '22 00:10

Aliostad