web services overloaded methods
-
Can you use overloaded functions in Web Services? I have to build a web service here at work and to get used to it I wanted to build a simple calculator. (it's my first Web Service, but I have built several ASP.NET apps.) when I use eg.
public int Add(int op1, int op2){}
there is no problem. If I however would add another function eg.public double Add(double op1, double op2){}
My app crashes with a server 500 error. ([WebMethod] attributes are set) Is this normal? tnx! "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix -
Can you use overloaded functions in Web Services? I have to build a web service here at work and to get used to it I wanted to build a simple calculator. (it's my first Web Service, but I have built several ASP.NET apps.) when I use eg.
public int Add(int op1, int op2){}
there is no problem. If I however would add another function eg.public double Add(double op1, double op2){}
My app crashes with a server 500 error. ([WebMethod] attributes are set) Is this normal? tnx! "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi HendrixWeb services don't really support overloading. You can implement both methods with the same name, but you will need to have different names for the WebMethod. So you could have
[WebMethod(MessageName="AddInt")] public int Add(int op1, int op2) {} [WebMethod(MessageName="AddDouble")] public double Add(double op1, double op2){}
To the outside world there will be two different methods. That is the closest you can come to overloading with Web Services. (Hopefully someday it will be different.) Torin Blair - MCP
'In the immortal words of Socrates - "I drank what?".'