I saw you resolving this issue differently,
In this case, when using JAXRS, you'd have to use JAXBElementProvider
directly, the option below should also work, but for JAXB classes, I
think I mislead you with my suggestion given that you used DOMSource
Sergey
On 25/04/13 19:42, Poindexter, Miles wrote:
Thank you Sergey,
Yes, this is a REST service built on a JAXWS Provider.
I have tried doing it two ways, one way uses an OSGi bundle activator to
create the HTTP endpoint, and there is no configuration file. So I don't
know how to set the JAXB Marshaller property, because the only object I'm
seeing is the DOMSource.
The other way I tried it is with regular JAXB annotations creating REST
service and giving it an HTTP endpoint by using a blueprint configuration
file. This would be my preferred way to create REST services going
forward.
But I don't know how to set the JAXB Marshaller property in the blueprint
file. I tried this:
<bean id="greetingBean" class="com.cn.dsa.service.GreetingServiceImpl"/>
<jaxrs:server id="greetingService" address="/greeting">
<jaxrs:serviceBeans>
<ref component-id="greetingBean" />
</jaxrs:serviceBeans>
<jaxrs:dataBinding>
<bean class="org.apache.cxf.jaxb.JAXBDataBinding">
<property name="marshallerProperties">
<map>
<entry>
<key><value>com.sun.xml.bind.xmlDeclaration</value></key>
<value type="boolean">true</value>
</entry>
</map>
</property>
</bean>
</jaxrs:dataBinding>
</jaxrs:server>
But I get this error:
org.apache.cxf.interceptor.Fault: Unmarshalling Error:
javax.xml.transform.dom.DOMSource is not known to this context
at
org.apache.cxf.jaxrs.provider.DataBindingProvider.readFrom(DataBindingProvi
der.java:76)
at
org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBodyReader(JAXRSUtils.
java:1189)
at
org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBody(JAXRSUtils.java:1
137)
at
org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:686)
at
org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:646
)
at
org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInI
nterceptor.java:237)
at
org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInIn
terceptor.java:98)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
n.java:271)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationO
bserver.java:121)
at
org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDe
stination.java:239)
at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(Servle
tController.java:218)
at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController
.java:163)
at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController
.java:137)
at
org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringSer
vlet.java:158)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(Abstract
HTTPServlet.java:243)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPSer
vlet.java:163)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
. . .