views:

114

answers:

2

I'm green hand in web-service. I wrote a generic class as a value holder like this:

public class SearchResult<T> {
    private List<T> resultSet;
}

Then I write a web-service method:

public SearchResult<Book> getSearchResult(){
    ...
}

When I was using maven-jaxws-plugin to generate client files, I found that the generic type information was gone. They looked like :

public class SearchResult {
   private List<Object> resultSet;
}

public SearchResult getSearchResult(){
    ...
}

My question here is, do the jaxws can keep such kind of generic type information? I tried List as return type, it does work. Thanks in advance for your help.

+1  A: 

Not sure of any other possibilities, but we are using

public class Books extends SearchResult<Book> {

}

Works quite well (as long as you don't have too many different types).

sfussenegger
+1  A: 

If the client code is generated using anything but the source, it will likely not contain the generic information. Once code using generics is compiled, information about generics is lost due to type erasure.

Alan Krueger