Method OverLoading in WCF, Exposing Overloded methods from wcfservice

By TSN ...

How to Expose a overloaded mehod from a wcf service Contract.

As you know when we expose any method from the WCF Service it is exposed by the Method Name , So when you have overloaded methods then there would be problem in exposing the Methods as they have same name.

We can overcome this by using Name attribute in the the Operation contract which gives the alias name for that method .
So the Method is exposed with that name.


[OperationContract(
Name=”ChangePasswordWithOld”)]
  
int ChangePassword(string userName, string oldPassword, string newPassword);

[OperationContract(
Name=”ChangePasswordWithQuestion”)]
  
int ChangePassword(string userName, string Question, string Answer);

Now the methods are exposed with alias names.

Method OverLoading in WCF, Exposing Overloded methods from wcfservice  (1544 Views)