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.
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.
On our side we usually version the operatiom via namespace. When an operation is deprecated we just put a deprecation comment in the description which the client can see through the wsdl. We notify our clients and let them know about the deprecated operations and when its expiration date is going to be.
I agree with @Aliostad that you shouldn't remove operations from the service contract in general as it introduces breaking change and as such should be avoided in single version of API.
However, if you want to inform client/consumer about some planned changes or have any other need to add certain "extra" information to the operation contract, you might take a look at IWsdlExportExtension interface, create a custom attribute that implements it and annotate particular operations.
You may take a look at this article for detailed reference.