JAVA RMI wrong return type generated by WSimport tool

Tags: ,



I am building a web service that includes some methods to do a specific job here is one of the web inferface methods:

@WebMethod
public DatingUserInfo[] GetAll(String gender);

this method should return an array of DatingUserInfo the implimentation of this method is:

@Override
    public DatingUserInfo[] GetAll(String gender) {

        DatingUserInfo[] ret_arr;
 ArrayList<DatingUserInfo> usrs=new ArrayList<DatingUserInfo>();

//fill the list with objects of DatingUserInfo//

 ret_arr= new DatingUserInfo[usrs.size()];
        usrs.toArray(ret_arr);
        return ret_arr; 
}

in the client-side when running the WSimport tool to get the required file I get this in one of the generated files:

 @WebMethod(operationName = "GetAll")
    @WebResult(targetNamespace = "")
    @RequestWrapper(localName = "GetAll", targetNamespace = "http://datingsvr/", className = "client.GetAll")
    @ResponseWrapper(localName = "GetAllResponse", targetNamespace = "http://datingsvr/", className = "client.GetAllResponse")
    @Action(input = "http://datingsvr/DatingServer/GetAllRequest", output = "http://datingsvr/DatingServer/GetAllResponse")
    public List<DatingUserInfo> getAll(
        @WebParam(name = "arg0", targetNamespace = "")
        String arg0);

    }

the returned type is List instead of DatingUserInfo[], what could cause that to make WSimport generates a wrong code?!

thanks in advance.

Answer

WSimport tool automatically by default replaces returned arrays to lists.



Source: stackoverflow