Thursday, November 8, 2012

Method Overloading in C# web services

There is a little bit problem when you want to overload a method in C# web services.
If you create methods in same name and different parameters , it will build successfully.
But when you want to debug or run it it will says you to ,


Use the MessageName property of the WebMethod custom attribute to specify unique message names for the methods.


So you should change some code to make method overloading.



use :  



[WebService(Namespace = "MYFIRSTWS")]
    [WebServiceBinding(ConformsTo = WsiProfiles.None)]
    [System.ComponentModel.ToolboxItem(false)]

and

[WebMethod(MessageName = "your_name_method")]


insted of : 

[WebService(Namespace = "MYFIRSTWS")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]

and

[WebMethod]


Thanks and regards.


No comments:

Post a Comment