Yeah that was the first thing I tried but I keep getting ClassCastException whenever I try to downcast an object from the list to either ObjectOne or ObjectTwo. I now also tried to use @XmlSeeAlso in the BaseObject but that made no difference (@XmlSeeAlso(value = { ObjectOne.class, ObjectTwo.class }))
If I use List<Object> I also get an exception: java.lang.ClassCastException: org.apache.xerces.dom.ElementNSImpl Ronald dkulp wrote: > > On Monday 01 December 2008 4:26:20 am Ronald Pieterse wrote: >> In my webservice I would like to be able to accept a list of different >> types of objects. So the client would send a list of different objects >> and >> the server would then be able to see which object is which. >> I understand that JAXB does not handle interfaces. Is there maybe another >> way to get this working if it is at all possible? > > JAXB doesn't really handle interfaces, but it does handle object > heiarchies. > If you have a "BaseObject" and ObjectOne and ObjectTwo both subclass it, > a "List<BaseObject>" would work just fine. You may need to add some > @XmlSeeAlso annotations to point at ObjectOne and ObjectTwo so the JAXB > runtime will know about them, but that's relatively minor. > > Alternatively, you CAN just have "List" (which maps to a xsd:any) and > use the XmlSeeAlso to point at ObjectOne and ObjectTwo and throw them in > the > list. JAXB can also handle that. It kind of depends on what you want > the > resulting schema to look like. > > Dan > > >> To clearify, I imagine something like: >> >> <object-type-one> >> <prop-one>...</prop-one> >> </object-type-one> >> <object-type-two> >> <prop-two-one>...</prop-two-one> >> <prop-two-two>...</prop-two-two> >> </object-type-two> >> >> and then both objects would maybe extend or implement something. Probably >> a >> little vague but hope you understand what I mean :-) >> >> Greetz, >> >> Ronald > > > > -- > Daniel Kulp > [EMAIL PROTECTED] > http://dankulp.com/blog > > -- View this message in context: http://www.nabble.com/Different-object-types-in-list-tp20768640p20789736.html Sent from the cxf-user mailing list archive at Nabble.com.