Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF contract changes that affect clients

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.

like image 664
Andy White Avatar asked Mar 11 '09 02:03

Andy White


People also ask

Which contract in WCF defines the type of data passed from service to client?

A Data Contract defines what data type to be passed to or from the client. In the WCF service, the Data Contract takes a major role for serialization and deserialization.

Which contract type is not supported by WCF?

There's nothing wrong. The WCF Test Client is a tool which can be used to test many types of WCF services, but not all of them - duplex contracts being one category which is not supported.

What is WCF behavior?

Behaviors enable you to modify default behavior and add custom extensions that inspect and validate service configuration or modify runtime behavior in Windows Communication Foundation (WCF) client and service applications.

What are types of contract supported in WCF?

WCF has five types of contracts: service contract, operation contract, data contract, message contract and fault contract.


2 Answers

OK. Question. Due to wrong naming syntax (parameter is specified with capital letter), I would like to adjust some code:

[OperationContract]
public void Foo(string Bar){}

to

[OperationContract]
public void Foo(string bar){}

Would adjusting the capital break contract?

like image 134
Samjongenelen Avatar answered Oct 16 '22 10:10

Samjongenelen


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.

like image 27
Jonathan Parker Avatar answered Oct 16 '22 11:10

Jonathan Parker