Overloaded Methods as WCF OperationContracts

Interesting find today.  It is possible to create a WCF Service Contract that has overloaded methods on it.  The compiler doesn't complain at all. You can even attribute both as [OperationContract] and the compiler still won't complain.  If you go to use that Service Contract though, it will blow up and thrown an error about duplicate naming.  While this is frustrating you can get around it.  Options include, changing the name of one of the Operation Contracts or setting the name parameter on the Operation Contract attribute (i.e. [OperationContract(Name="SomeUniqueName")]).

posted @ Wednesday, May 28, 2008 1:30 PM

Print

Comments on this entry:

# re: Overloaded Methods as WCF OperationContracts

Left by Rob Kitson at 5/28/2008 1:42 PM
Gravatar
Another thing that I found was cool is that the arguments that your methods accept can be polymorphic. You just have to declare what types it will accept, which can be done by hand (with an attribute for each sub-class) or by creating a static method that returns a list of all the types that inherit from a base class.
Comments have been closed on this topic.