How perform overloading and overriding in WCF? What is different between both in WCF? [Resolved]

Posted by Kumarkrishna184 under WCF on 3/30/2016 | Points: 10 | Views : 771 | Status : [Member] | Replies : 1
How do we perform overloading and overriding in WCF? What is different between both in WCF? Please describe it in detail....

Thanks and Regards,
Krishna Kumar



Responses

Posted by: Allemahesh on: 3/30/2016 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
Method overriding is not possible in WCF

Method overloading is not allowed in WCF. But you can explicitly specify the Name property of the OperationContract. See the below example:-

//Error - will throw an InvalidOperationException while hosting
[ServiceContract]
public interface MyService
{
[OperationContract]
int Sum(int x, int y);

[OperationContract]
int Sum(double x, double y);
}


//Valid one
[ServiceContract]
public interface MyService
{
[OperationContract(Name="SumUsingInt")]
int Sum(int x, int y);

[OperationContract(Name="SumUsingDouble")]
int Sum(double x, double y);
}


For the WCF Method Overloading, see the link http://www.c-sharpcorner.com/UploadFile/akkiraju/wcf-method-overloading/

Kumarkrishna184, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response