Sunday, May 6, 2012

Method Overloading in WCF

public interface IGetEmployee
    [OperationContract(Name = "GetEmployeeDetailsById")]
    List GetEmployeeDetails(int id);

    [OperationContract(Name = "GetEmployeeDetailsByName")]
    List GetEmployeeDetails(String name);

     we can achive the method overloading through the name attribute of the operation contract set the alias name for the method .method name will appear based on the proxy class generation If you use the proxy class that is automatically generated by svcutility.exe, the alias method names will be used. However, you can manually edit the generated proxy class to achieve the appearance of overloaded methods on the client as well.This can be accomplished by applying the same attributes to the methods defined in the interface that is used by the proxy class.