tags:

views:

171

answers:

4

I have built a regular .NET asmx service. How do i overload web methods in this service?

+5  A: 

WS-I (web services interoperability) does not support overloading.

Martin v. Löwis
You can do it by disabling WS-I compatibility, but I can't bring myself to propose that as an answer ;-p To all sensible intents, this is (IMO) the right answer.
Marc Gravell
A: 

No. Web Service method names must be unique.

Justin Niessner
+1  A: 

Yes.

The WebMethod attribute takes a MessageName parameter that allows you to "overload" the method.

Patrick
+6  A: 

You can't really overload a web method. When you think about it, this makes sense because a web method is designed not to rely on underlying technologies such as OO languages, as it can theoretically run in things like COBOL.

While you can write a web method that looks like it can be overloaded, you actually have to assign it a different name, as in:

[WebMethod]
public void Add(int x, int y)
{
}
[WebMethod(MessageName="AddFloat")]
public void Add(float x, float y)
{
}
Pete OHanlon