WCF contract changes that affect clients

Andy White picture Andy White · Mar 11, 2009 · Viewed 12.1k times · Source

I was curious if someone could outline which types of WCF contract (interface) changes on the server side would break a client trying to send in a message, and why. I believe WCF can handle certain discrepancies, but I'm not sure exactly what you can change safely, and what you can't.

  • Add/remove parameters from an OperationContract?
  • Add/remove/change the DataContract's serialized properties?
  • Add/remove OperationContracts from a ServiceContract?

A friend asked a similar question here:

Does adding a method to a WCF ServiceContract break existing clients?

EDIT: As John Saunders pointed out, changing the contract is not usually a good idea, but there are things built in that allow for some version tolerance (ExtensionDataObject, etc.?). I would just like to know how flexible the version tolerance is.

Answer

Jonathan Parker picture Jonathan Parker · Mar 11, 2009

Check out this article on dasBlonde: Versioning WCF Service Contracts

It lists what changes will break existing clients:

  1. Remove operations
  2. Change operation name
  3. Remove operation parameters
  4. Add operation parameters
  5. Change an operation parameter name or data type
  6. Change an operation's return value type
  7. Change the serialized XML format for a parameter type (data contract) or operation (message contract) by explicitly using .NET attributes or custom serialization code
  8. Modify service operation encoding formats (RPC Encoding vs. Document Literal)

This article by Michele explains in more detail how you can design contracts to be more flexible.