top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How we can achieve Operation Overloading while exposing WCF Services?

+3 votes
404 views
How we can achieve Operation Overloading while exposing WCF Services?
posted Jan 26, 2014 by Prachi Agarwal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

By default overload operations (methods) are not supported in WSDL based operation. However by using Name property of OperationContract attribute, we can deal with operation overloading scenario.

[ServiceContract]

interface ICalculator    
{    
   [OperationContract(Name = "AddInt")]    
   int Add(int arg1,int arg2);    

   [OperationContract(Name = "AddDouble")]    
   double Add(double arg1,double arg2);    
}

Notice that both method name in the above interface is same (Add), however the Name property of the OperationContract is different. In this case client proxy will have two methods with different name AddInt and AddDouble.

Credit: http://www.dotnetfunda.com/

answer Jan 26, 2014 by Sheetal Chauhan
...