Hide Service Method Name from Client in WCF

Commonly we discuss about whether WCF supports overloading or not. The answer is simple, WCF doesn't support overloading because WSDL (Web Service Definition Language) does not support OOPs features. But we can achieve this by the different values of "Name" attribute of "OperationContract" in WCF service.
 
There is also one hidden feature in WCF service through that we can hide the service methods name from client. We can achieve this in the same way by the different values of "Name" attribute of "OperationContract". So now the method name exposed on the client side is not the one created on server side, but the value we assigned to the "Name" attribute of "OperationContract".
  1. [ServiceContract]  
  2. interface IMyService  
  3. {    
  4.    [OperationContract(Name = "AddInt")]  
  5.    string Addition(int v1, int v2);  
  6.   
  7.    [OperationContract(Name = "AddString")]  
  8.    string Addition(string v1, string v2);   

So client will see "AddInt" & "AddString" not "Addition", therefore we can use this feature for security purpose.
Ebook Download
View all
Learn
View all