Home » csharp » Overload Webservice.

Overload Webservice.

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

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

you must change webservice code as follows
 [WebMethod(Description = &quot;AddTwoNumber&quot;)]<br />
    public int Add(int a, int b)<br />
    {<br />
        return a + b;<br />
    }<br />
    [WebMethod(Description = &quot;AddThreeNumber&quot;)]<br />
    public int Add(int a, int b, int c)<br />
    {<br />
        return a + b + c;<br />
    }<br />

However, we may also get errors if
 [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]<br />

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)]<br />

Leave a Reply

Subscribe

Join 901 other subscribers