File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes Why does not JAXB bind java.util.Map properly but handles java.util.List Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "Why does not JAXB bind java.util.Map properly but handles java.util.List" Watch "Why does not JAXB bind java.util.Map properly but handles java.util.List" New topic
Author

Why does not JAXB bind java.util.Map properly but handles java.util.List

Ravi C Kota
Ranch Hand

Joined: Jan 29, 2008
Posts: 61
Hello All,

Some where I read, in this forum that usage of Collections is not recommended as JAXB will not be knowing how to bind them. So, in order to understand the problem, I started writing a sample code. The code looks as below



So as seen above, I'm trying to see how the binding works for different kinds of object types. I ran the wsgen against the above code, but would end up with the exception



The exception is misleading here, as it sounds as if an Interface can not be used as a return type here. For that matter, List is also an interface and I do not see any issue for List. It is also failing for getDatabase() for the same reason as that of Map.

Using the Interface as the return type is the quite common and also highly respected way of coding. But apparently I'm missing something here to get it work. Can someone point me out the mistake I'm making here and a corrective action.


Thanks & Regards, Ravi C.Kota
SCJP 5.0, OCDJWS 5.0
Rajkishore Pujari
Ranch Hand

Joined: Sep 03, 2005
Posts: 46
This link may help in answering your question a bit

http://weblogs.java.net/blog/2006/06/06/jaxb-and-interfaces
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why does not JAXB bind java.util.Map properly but handles java.util.List