Hi,
My question is WCF Service support method overloading or not ?
Thanks
WCF Service
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
MuthuMari MRank #5,738 · 288 reputationPosted Apr 25, 2012, 8:40 PM EDT
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"
SenthilkumarRank #387 · 6.5K reputationPosted Apr 26, 2012, 12:11 AM EDT
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