Hi,
My question is WCF Service support method overloading or not ?
Thanks
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
SenthilkumarPosted Apr 26, 2012, 4:11 AM
Physically you can have the overloading while defining the operation contracts which exposes as web methods to the cusumers.
But it should be with the different name.
For example,
[OperationContract]
void ShowNames(string name)
[OperationContract]
void ShowNames(string name1, string name2)
Here i have overloaded two web methods. But in the proxy client you can't have two methods with the same name.
It should be renamed through the Name property in the operationcontract.
[OperationContract]
void ShowNames(string name)
[OperationContract[Name="ShowTwoNames"]
void ShowNames(string name1, string name2)
For more info:
http://www.c-sharpcorner.com/uploadfile/dhananjaycoder/operation-overloading-in-wcf/
http://jeffbarnes.net/blog/post/2006/09/21/Overloading-Methods-in-WCF.aspx
MuthuMari MPosted Apr 26, 2012, 12:40 AM
A WCF Service doe not allow normal method overloading , which is supported by .NET. It throws InvalidOPerationException.
pls refer this url for more info:
http://www.dotnetfunda.com/interview/exclusive/x4706-wcf-interview-questions-can-we-do-method-overloading-in-wcf-service.aspx
thanks.
If this post is useful then mark it as "Accepted Answer"