I would like to implement method overloading in the Java web service class as follows:
public String myMethod(User user)
{
// My code
}
public String myMethod(User[] user)
{
for(int i=0; i<user.length; i++)
{
myMethod(user[i]);
}
}
If I forward a single User
object to myMethod()
, it should trigger the first method and if I send an array of User
s, it should trigger the second method.
In the WSDL file it shows only a single method. However, if I try to call @WebMethod(operationName="")
for both calls, I am unable to generate the WSDL file.
Operation overloading is not allowed for web services.
It is explicitely prohibited in WS-BP and WSDL 1.2 also disallows it.
Even if you found a stack that has some support for this I would recommend not to follow this approach.
Overloading is an OO
concept. Don't try to apply them to Service Oriented
paradigm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With