Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Donald DUCK : YOU ARE FIRED!!!
  • Administrators
Posted

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.

 

[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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...