Skip to content

JAVA RMI wrong return type generated by WSimport tool

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

public DatingUserInfo[] GetAll(String gender);

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

    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()];
        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.



WSimport tool automatically by default replaces returned arrays to lists.

User contributions licensed under: CC BY-SA
8 People found this is helpful