You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by John Mikhail <jm...@gmail.com> on 2008/05/26 01:40:46 UTC
RESTful service returning objects that don't have XmlRootElement
Hello,
So for the RESTful service I'm writing, I generated my data model from a
third party xsd. All the objects created there don't have a @XmlRootElement
annotation, but rather just @XmlType. So when I return these objects from my
RESTful service, I'm now getting:
.No message body writer found for response class : LocationOptionsType.
I dug around online and didn't really find anything helpful. I did find one
post that said there should be an ObjectFactory that has methods that I can
use to wrap my classes in a JAXBElement. I tried using that, but everything
I'm doing returns that error.
I tried modifying my method signature to return the object itself, the
JAXBElement wrapped object, and even a Response, but all the same. Has
anyone run into this issue?
Thanks in advance,
John
Re: RESTful service returning objects that don't have XmlRootElement
Posted by Sergey Beryozkin <se...@iona.com>.
Hi
Support for JAXBElement and custom ContextResolvers is coming very shortly. I'm slowly doing some CXF JAX-RS background work around fixing various issues and upgrading it to later api versions. Still, there's a possible workaround : you can simply copy and paste an existing JAXBProvider and in its writeTo() element add a check :
if (JAXBElement.class is assignable to a passed in Class type) then pass in the type/object returned from the JAXBElement to the the JAXB marshaller instead...and then register it from Spring and your provider will be picked up and used...
Cheers, Sergey
> Hello,
>
> So for the RESTful service I'm writing, I generated my data model from a
> third party xsd. All the objects created there don't have a @XmlRootElement
> annotation, but rather just @XmlType. So when I return these objects from my
> RESTful service, I'm now getting:
>
> .No message body writer found for response class : LocationOptionsType.
>
> I dug around online and didn't really find anything helpful. I did find one
> post that said there should be an ObjectFactory that has methods that I can
> use to wrap my classes in a JAXBElement. I tried using that, but everything
> I'm doing returns that error.
>
> I tried modifying my method signature to return the object itself, the
> JAXBElement wrapped object, and even a Response, but all the same. Has
> anyone run into this issue?
>
> Thanks in advance,
>
> John
>
----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland