Sep 28 2007

Method Overloading in WebServices

Category:Bil@l @ 13:11

Sometimes there is a need to have two Web methods with the same name but off course different number of parameters. When developing Web Services, it is not enough to just ad two methods with different parameters as you do when developing an API.

In Web Services you need to specify MessageName to be different for each overload method as follows:

[WebMethod(MessageName="LogMessage1"),
    SoapDocumentMethod(OneWay=true)
]
public void LogMessage(string message)
[WebMethod(MessageName="LogMessage2"),
    SoapDocumentMethod(OneWay=true)
]
public void LogMessage(string message, string userName)

 

Hope this helps,
Regards

 

Tags:

Comments are closed