Operation Overloading in WCF
Programming such C++ and C# support method overloading;
that is, defining two methods with the same name but with different paramaters.
interface IUser
{
int AddUser(string
UserName, string password);
int AddUser(string
UserName, string password, string EmailID);
}
This is a valid interface in C#.
However, operation overloading is invalid in WSDL based
operations, since all operations must have unique names (they are identified by
name in the messages).
[ServiceContract]
interface IUser
{
[OperationContract]
int AddUser(string UserName, string
password);
[OperationContract]
int AddUser(string UserName, string
password, string EmailID);
}
This contract definition is invalid
and it will throw an InvalidOperationException
at the service host load time.
However, you can manually enable
operation overloading. The trick is using the Name property of the OperationContract attribute to alias
the operation:
[AttributeUsage(AttributeTargets.Method)]
public sealed class OperationContractAttribute : Attribute
{
public string
Name
{ get; set;
}

Reeta Singh LodhiPosted Feb 16, 2011, 12:36 AM
Thanks for blog, very nicely explained.
Mukesh KumarPosted Feb 14, 2011, 11:34 AM
Yes. But you can use generated proxy and contract for client as they are in the service. For more detail go through my next blog "How to use generated proxy and contract for client as they are in service when using "Operation Overloading" in WCF".
Reeta Singh LodhiPosted Feb 14, 2011, 6:25 AM
Does that mean at client side we have two functions named- AddUser and AddUserWithEmail ?
Amit ChoudharyPosted Feb 14, 2011, 2:32 AM
Yes we can overload our methods.. same we do in overloading the webmethods in webservices... using the "Name Attribute". and this is the key point of this blog.. nice post mukesh..