WCF/WF - WCF -how to change the service /operation contract name without breaking the clients -prox

Asked By karur krishna madhu on 03-Apr-14 08:43 AM
I have declared a operation contract in a service contract.

 // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "ISalesService" in both code and config file together.
    [ServiceContract]
    public interface ISalesService
    {
        [OperationContract]
        int getsalesordercount(int salesempid); 


    }
Now i want to change the interface ISalesService name or operation contract getsalesordercount. if i change that then all the existing clients will get contract mismatch exception . to avoid this i will have to add name attribute to the service contract or operation contract as mentioned below. My question is once i declare the service contract name or operation contract name under what circumstances i may have to change the names of the operation method or service contract?

[ServiceContract(name="salesorgservice"]
    public interface ISalesService
    {
        [OperationContract(name="salesorgmethodservice"]
        int getsalesordercount(int salesempid); 


    }
Regards
Krishna.K
Robbe Morris replied to karur krishna madhu on 03-Apr-14 11:11 AM
The way this is typically done is that you put virtually all of the logic for your wcf web method in a separate class (or classes) and method(s) outside of the code behind in your .svc file.  Only the least amount of code to call that logic would exist in the web method stubs.

Then, you can simply create a new endpoint (svc file) when you release new versions of your service.  You are not duplicating the important logic.  You are just duplicating the web method stubs and tweaking them as needed.  They'll still call your code logic in your classes used across many endpoints in your WCF service.

You contact the people who are clients of your service and let them know that version 1.1 is ready and is available at xyz.svc.

This gives them a chance to modify their client apps to contend with the differences in the interface from version 1.0 and 1.1 and start using 1.1 when they are done testing.

This gives you a great deal of flexibility and reliability.
karur krishna madhu replied to Robbe Morris on 04-Apr-14 06:19 AM
Thanks Morris!