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
2009-10-05 21:52:00
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
2009-10-05 21:54:18
+1
A:
Yes.
The WebMethod attribute takes a MessageName parameter that allows you to "overload" the method.
Patrick
2009-10-05 21:54:35
+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
2009-10-05 21:58:02