Home » csharp » Overload Webservice.

Overload Webservice.

TO workout the error when we overload the [WebMethod] like the following

[WebMethod]
    public int Add(int a, int b)
    {
        return a + b;
    }
    [WebMethod]
    public int Add(int a, int b, int c)
    {
        return a + b + c;
    }

you must change webservice code as follows

 [WebMethod(Description = "AddTwoNumber")]
    public int Add(int a, int b)
    {
        return a + b;
    }
    [WebMethod(Description = "AddThreeNumber")]
    public int Add(int a, int b, int c)
    {
        return a + b + c;
    }

However, we may also get errors if

 [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 

which is the auto generated while adding webservice in visual studio

So we need to remove or comment the above line

 //[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 

Leave a Reply

Subscribe

Join 901 other subscribers