Let's say i have the following strucutre
public class Mammal
{
@WebMethod
public ArrayList<Mammal> getAll(){ return null; }
@WebMethod
public String speak(){ return "Unable to speak"; }
@WebMethod
public Mammal me(){ return this; }
}
@WebService
public class Human extends Mammal
{
@WebMethod
public ArrayList<Human> getAll(){ /* code to return all humans as ArrayList<Human> */ }
@WebMethod
public String speak() { return "Hai!"; }
@WebMethod(operationName="GetHuman")
public Human me(){ return this; }
}
Now If you see the Mammal me() and Human me() are overided natuarlly and this works perfectly and the WSDL is generated as it should be because that i add the operationName="".
So far so good, now the method returning an ArrayList does not work. Somehow it says that ArrayList can't override ArrayList which in my opinion should be possible?
Now I found a work-around for this and the result looks as followed
In the Mammal class I have this instead: public ArrayList getAll(){ return null; }
And i leave the Humna-class untouched, now this works.
However! This makes it Impossible to extending a Human and overriding the method from a new sub-class, so I am back at square one again.
How do I solve this?
Let's say I want to access the Webservice from a C# application then i want the method to have a return type of List Human or List Whatever-extended-Mammal, Without having to type-cast on the other side!