Geeks With Blogs
Dheeman Dutta Just Another Blog.....

You all may have found this one out even earlier, but I found this out just a few days before. A WCF Service doe not allow normal method overloading , which is supported by .NET. It throws InvalidOPerationException.

As for the reasons to why this happens is becasue WSDL is not a object orinted language and does not support these features of OOP. However overloading can be performed in WCF service in a roundabout way.

[ServiceContract]
interface ICalculator
{
 [OperationContract(Name="AddIntegers")]
 int Add(int a,int b)

 [OperationContract(Name="AddDouble")]
 double Add(double a,double b)
}

The Name property in the OperationContract attribute enables the WSDL to make the difference between to same named methods here.

 

Cheers

 

 

 

 

 

Posted on Wednesday, January 27, 2010 2:39 PM | Back to top


Comments on this post: WCF Service Method Overloading

# re: WCF Service Method Overloading
Requesting Gravatar...
Hello All,

Below is the link that provide good explanation of possibility of Method overloading and trick to achieve Method overloading in SVC

http://aspdotnethacker.blogspot.com/2010/07/wcf-service-method-overloading.html
Left by sandeep on Jul 10, 2010 3:26 AM

# re: WCF Service Method Overloading
Requesting Gravatar...
nice reply
Left by Dinesh on Mar 21, 2012 4:42 PM

Your comment:
 (will show your gravatar)


Copyright © Dheeman Dutta | Powered by: GeeksWithBlogs.net