Can I have an optional parameter for an ASP.NET SOAP web service

后端 未结 6 2042
[愿得一人]
[愿得一人] 2020-11-29 12:30

I want to build a webservice with this signature, which does not throw an exception if param2 is left empty. Is this possible?

[WebMethod]
public string Hell         


        
6条回答
  •  半阙折子戏
    2020-11-29 12:50

    I know this post is little old. But I think the method names should be same for the example from Rasik. If both method names are same, then where overloading comes there. I think it should be like this:

    [WebMethod(MessageName="Add3")]
    public double Add(double dValueOne, double dValueTwo, double dValueThree)
    {
       return dValueOne + dValueTwo + dValueThree;
    }
    
    [WebMethod(MessageName="Add2")]
    public int Add(double dValueOne, double dValueTwo)
    {
       return dValueOne + dValueTwo;
    }
    

提交回复
热议问题