Wednesday, May 10, 2017

Backward compatible WCF contract changes



Most importantly, the following operations will not cause old clients to break:

Service contracts (methods)

Adding method parameters: No break,The default value will be used when called from old clients.
If you have add a parameter in a function than WCF use default value concept automatically for this method.

Removing methods parameters: The values sent by old clients will be ignored silently.

If you have removed any parameter from any existing method, than client still not break. The extra parameter will be ignore by service itself.

Adding new methods: Obviously, old clients won't call them, since they don't know them.

If you have added new method in service than client still not break, since client has not any knowledge of this new method.

Modifying parameter types : An exception will occur if the incoming type from the client cannot be converted to the parameter data type.

If you have modify the parameter type whether it is passed or return WCF will try to convert passed parameter to the desired if it does not succeed than throw an error,

Adding new methods: Obviously, old clients won't call them, since they don't know them.

Removing existing methods: An exception will occur.


Data contracts (custom classes for passing data)
  1. Adding non-required properties. No error

  1. Removing non-required properties. : throw exception

Thus, unless you mark the new DownloadLink field as IsRequired (default is false), your change should be fine.

No comments:

Followers

Link