Thursday, 27 September 2012

Method OverLoading In WCF

Can you overload methods in a WCF service?

Yes, it is possible to overload methods in a WCF service, but the names of the exposed operation contracts must be unique. To achieve this we can use the Name property of OperationContractAttribute. Let us understand this with an example.

If I have the WCF service designed as shown below, the service compiles without any issues. When we try to run the service, we will get InvalidOperationException.






o correct this we can use the Name property of OperationContractAttribute as shown below. After this change, the service works fine both at compile and runtime.







No comments:

Post a Comment