WYSIWYG

http://kufli.blogspot.com
http://github.com/karthik20522

Thursday, March 15, 2012

WCF Data Contract Versioning

One of the greatest challenges when building any Webservice especially if it involves various clients connected is the issue of versioning. Following is possible version changes that WCF can handle by default:

Adding new Parameters to an OperationClient unaffected. New parameters initialize to default values at the service
Removing parameters from an operationClient Unaffected. WCF ignores old parameters, data lost at the service
Modifying Parameter typesException will occur if the incoming type from client is different from server
Modifying return value typesException will occur
Adding new operationsClient unaffected. Will not invoke operations it knows nothing about
Removing operationsException. It would be unknown action header


Operation contract changes possible solutions:
1) Service contract Inheritance
2) Brand new service contract with new namespace

Data contract changes
1) Adding IExtensibleDataObject
* ExtensibleDataObject is basically Key-Value dictionary
* This dictionary holds properties that old or future code contracts don’t have
* Basically it preserves the properties that don’t exists in the request or response
* Need to use svcutil.exe or visual studio reference to utilize this.
- By default all proxy class’s have this

Example:

Labels: ,