On Wednesday 03 December 2008 8:11:25 am Ronald Pieterse wrote:
> 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 - had to put it in the service
> interface so they would appear in my wsdl but it makes no difference
> (@XmlSeeAlso(value = { ObjectOne.class, ObjectTwo.class })); still a
> ClassCastException.
>
> If I use List I also get an exception: java.lang.ClassCastException:
> org.apache.xerces.dom.ElementNSImpl
>
> Am I doing something wrong here?It sounds like JAXB is not getting all the the classes somehow. You might need to try debugging a bit and putting a breakpoint in the "createJAXBContextAndSchemas" method of JAXBDataBinding to see what classes are in the set. However, if the classes are appearing in the wsdl, it looks like it's working properly on the server side. You may want to use wireshark or something to see the soap messages on the wire to see what they look like. They SHOULD have appropriate xsi:type="ns:ObjectOne" attributes on the elements. Dan > 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 -- Daniel Kulp [EMAIL PROTECTED] http://dankulp.com/blog
