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<Object>" (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

Reply via email to