I am writing a JAX-RS webservice . Which returns a Reponse back in form of application/xml .In that I have to produce CDATA sections . I have researched a lot and I have seen many blogs . But I am still not able to do so . I have tried following approaches:
1) Writing your own Jaxb2Marshaller as mentioned here : http://www.coderanch.com/t/584332/Web-Services/java/Spring-WS-JAXB-CDATA . And I have configured like below :
<bean id="marshaller" class="com.test.CdataJaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>com.test.MyModel</value>
</list>
</property>
<property name="cdataElements">
<list>
<value>Data</value>
</list>
</property>
</bean>
But I am not getting a call in marshall method of the CdataJaxb2Marshaller . I am wondering that I have configure the the marshaller inside the or somewhere else . Could someone suggest .
2) The second approach I have tried is mentioned here : http://mail-archives.apache.org/mod_mbox/cxf-users/201203.mbox/%3CCAEDT_BW49HTNZtad5P+GoGZLpLYTnEwO50dzUuPNKnpWsy=rdQ@mail.gmail.com%3E . But I doesn't talk about how to configure CdataWriterInterceptor inside I tried configuring as follows :
3) Third approach I tried is very similar to the the second , with the difference that instead of Interceptor I configured a provider , something thats mentioned here :
I don't want to use some third party stuff like eclipse link Moxy . Alas JAXB natively doesn't support CDATA sections . It would be great help if someone has an anwser to this problem.
Thanks, Aman.