In this post, I will go say some tips regarding change the service contract without affecting the existing client. Lets we see this through a sample. It is my service code and my configuration in the service.
Service Contract with one operation contract:
- [ServiceContract]
- public interface IHelloService
- {
- [OperationContract]
- string SayHello(string name);
- }
- Service Implementation
- public class HelloService: IHelloService
- {
- public string SayHello(string name)
- {
- return "Hello " + name;
- }
- }
- <system.serviceModel>
- <services>
- <service name="ServiceLib.HelloService" behaviorConfiguration="servicemex">
- <endpoint address="IHelloService" binding="basicHttpBinding" contract="ServiceLib.IHelloService"></endpoint>
- <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
- <host>
- <baseAddresses>
- <add baseAddress="http://localhost:8080" /> </baseAddresses>
- </host>
- </service>
- </services>
- <behaviors>
- <serviceBehaviors>
- <behavior name="servicemex">
- <serviceMetadata httpGetEnabled="true" /> </behavior>
- </serviceBehaviors>
- </behaviors>
- </system.serviceModel>
- ServiceRef.HelloServiceClient client = new ServiceRef.HelloServiceClient();
- Console.WriteLine(client.SayHello("Sakthikumar"));
Hello sakthikumar
If you have any doubt regarding creating service and capture in the client application, please refer this article.
If we make changes the service contract or operation contract after given to the client. It will throw the exception in the client application the client will not able access the service.
The changed service is like this code,
- [ServiceContract]
- public interface IHelloServiceUpdated
- {
- [OperationContract]
- string SayHello(string name);
- }
- public class HelloService: IHelloServiceUpdated
- {
- public string SayHello(string name)
- {
- return "Hello " + name;
- }
- }
An unhandled exception of type 'System.ServiceModel.ActionNotSupportedException' occurred in mscorlib.dll.
Additional information
The message with Action 'http://tempuri.org/IHelloService/SayHello' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
To resolve this problem, the WCF provide one way. That specifies the name to all contracts. The name attribute is available in the all contracts. For our sample, I go to specify the name to both service and operation contract here. The code will be,
- [ServiceContract(Name = "IHelloService")]
- public interface IHelloServiceUpdated
- {
- [OperationContract(Name = "SayHello")]
- string SayHello(string name);
- }

Anil Kumar MurmuPosted Jan 19, 2016, 2:50 AM
Thanks Sakthi for sharing. Hope we are able to see the upcoming articles for other scenarios also. For e.g. 1- number of parameters or type of parameters have got changed. 2-Return type of any operation contract changes. 3- If any DataMember has got modified(Added/Removed). 4- If any New ServiceContract has been introduced.
Santhakumar MunuswamyPosted Jan 13, 2016, 11:16 AM
Thanks for nice share