Exception when implement function overloading in WCF

Hi Folks,

If you tried to develop a simple WCF function, and you tried to write in your WCF 2 overloading functions in WCF, you will not be able to deploy your serivce and the clients will get an exceptions.

The solution: give Aliases to the overloaded functions in the WCF service.

Code :


public interface IMyWCFSvc
{
[OperationContract(Name=”GetCustomerById”)]
string GetCustomerInfo( int CustId);

[OperationContract(Name=”GetCustomerByEmail”)]
string GetCustomerInfo( string CustomerEmail);
}

The proxy when you reference to your serivce, will create 2 methods with the Alias names and not with the actual overloaded name in C# code.

Hope this helps.


Regards,
Mostafa arafa

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>