Mark obsolete fields in WCF contract

I have a wcf contract that works with client v1.

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

Are there any recommendations on this issue? Are there any existing attributes in WCF that I should use?

thanks.

+7
source share
3 answers

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

In terms of the WCF management version, once you have published the interface, you cannot delete any methods or, from a contract perspective, you really should not remove any properties. You can publish a new interface and create a separate DTO class if you want new clients to use it.

Ref: Deprecated attribute .

+12
source

On our side, we usually use the option through the namespace. When the operation is out of date, we simply put the deprecation comment in the description that the client can see through wsdl. We notify our customers and inform them of outdated operations and when it will expire.

0
source

I agree with @Aliostad that you should not delete operations from the service contract at all, since it introduces a change of shift and as such should be avoided in a single version of the API.

However, if you want to inform the client / consumer about some planned changes or you have any other need to add certain โ€œadditionalโ€ information to the work contract, you can take a look at IWsdlExportExtension , create a custom attribute that implements it, and annotate certain operations .

You can read this article in more detail.

0
source

All Articles