Method Overloading in WCF

by aboo bolaky 24. November 2008 07:32

In WSDL-based operations, method overloading is hard to achieve. It's not as easy as it would seem with C++ or even C#, where an interface could be defined as

public interface IHelloWorld
	void Add(int num1 ,int num2);
	void Add(string s1, string s2);

When you implement this interface in your class, the code (if it's well written Sealed) will compile just fine. The moment you update your service reference, it all goes crazy. The Error Message is "The Request failed with the error message : Cannot have two operations in the same contract with the same name".

The resolution is to add the Name attribute to the OperationContract on each method defined in the interface.

public interface IHelloWorld
	[OperationContract(Name="AddNumber") ]
	void Add(int num1 ,int num2);
	void Add(string s1, string s2);

When proxy is generated on the client, the operations now have aliased names.  NICE !!

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "")]
public interface IHelloWorld 
	void AddNumber(int num1, int num2);

	void ConcatenateStrings(string s1, string s2);



.Net | WCF | Tips & Tricks


5/10/2010 5:37:25 PM #

led bulb

The blogsphere changes rapidly, and change creates opportunity.

led bulb United States |

5/19/2010 12:22:44 PM #

latin shoes

thanks for your article

latin shoes United States |

5/19/2010 12:28:09 PM #

latin shoes

thanks for your article

latin shoes United States |

11/5/2011 9:15:49 AM #

reserver riad

Wohh precisely what I was looking for, looks for putting up. “The solely boulevard of intelligent a fellow is to cherish them without dream.” by Walter Benjamin.

reserver riad France |

11/5/2011 8:23:37 PM #

credit immobilier

It’s so amazing to gather information on the blog. I really loved reading these post. It has strengthen my faith more. You all do such a great job at such concepts.

credit immobilier France |

11/5/2011 10:23:16 PM #


How to pay off the mortgage early and wisely

While still working well and take the time to pay the mortgage on your home early and wisely. Leave your retirement to enjoy the beaches, your family and your home. One should not be charged for such things as mortgages and debt in their twilight years. M |

11/7/2011 9:09:58 AM #

Marrakech guide

Quite what I was searching for, esteem it for posting . “There are numerous victories worse than a surmount.” by George Eliot.

Marrakech guide France |

11/7/2011 2:15:32 PM #

Tout Marrakech

Truly stimulating info !Utopian true what I was searching for!

Tout Marrakech France |

11/10/2011 3:34:27 AM #

office chairs

nice page. need to check more. thanks for this post.

office chairs United Kingdom |

11/13/2011 8:01:43 AM #

sejour Marrakech

Merely covet to answer your report is as surprising. The clarity in your print is simply pretty and i can think you’re a professional on this subordinate. Well together with your warrant approve me to grab your eat to arrest updated with coming enter. Thank you alone million and delight support on the gratifying work.

sejour Marrakech France |

11/13/2011 1:28:17 PM #

Marrakech ici

Good blog! I truly charity how it is familiar on my ogles furthermore the material are well written. I’m wondering how I potency be notified whenever a recent inform has been made. I enjoy subscribed to your RSS which want do the gag! Enjoy a prominent period! “Reputation is what alternative mankind experience about you. Honor is what you know about yourself.” by Lois McMaster Bujold.

Marrakech ici France |

11/14/2011 4:44:26 PM #

assurance pret

I am very pleased to find this web site.I wanted to thank you for your time to write this wonderful post! Definitely enjoying every bit of it and I checked to see new things to blog.

assurance pret United States |

11/14/2011 4:44:43 PM #

assurance prêt

I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post.

assurance prêt United States |

11/14/2011 4:48:00 PM #

pret immobilier

Very useful blog! I really enjoyed reading it. So nice to read a blog that's written in proper way! I'll certainly be back again for more in the future. Thank you so much.

pret immobilier United States |

11/14/2011 4:50:41 PM #

prêt immobilier

I thought it was going to be boring and old site, but I'm glad when I visited, I will post a link to this page on my blog. I believe my visitors will find that very useful.

prêt immobilier United States |

11/14/2011 5:00:53 PM #

crédit immobilier

Hi, I would suggest you to continue posts, this would make your blog even more n more interesting and popular, and I guess you will get more.

crédit immobilier United States |

11/15/2011 7:07:13 PM #

immobilier a vendre au maroc

As I website owner I comprehend the capacity here is tangible exquisite , looks for your struggles.

immobilier a vendre au maroc France |

Tag cloud

Flash Player 9 required.

About Me

I wish I could write something here..
//TODO: ElaborateMe