Web Service Methods

microkarl

Regular
Joined
Apr 22, 2004
Messages
88
Location
Morristown, NJ
Hi all,
I have a question about web methods in .NET Web Service. I know that it is illegal to have overloaded web methods in web service. But why? Does anyone know? Can I get some information about it somewhere???

Thanks,
Carl
 
It's a restriction on how web services work, all methods need a unique name. With .Net though you can use the MessageName parameter of the WebMethod attribute to work round this restriction - simply give each overload a different messge name.

C#:
[WebMethod(MessageName="HeloWorld")]
public string HelloWorld()
{
	return "Hello World";
}

[WebMethod(MessageName="HelloPlace")]
public string HelloWorld(string place)
{
	return "Hello " + place;
}

This will give the methods different names in the WSDL, however if you then create a client to the webservice .Net will just give you an overloaded HelloWorld method.
 
Back
Top