You need to set the content-type on the endpoint, not on the service factory bean: e.g.

   <jaxws:endpoint id="catalogJsonWS"
       implementor="#catalogRest"
       address="/json/Catalog"
       bindingUri="http://apache.org/cxf/binding/http";>
       <jaxws:properties>
           <entry key="Content-Type" value="text/plain"/>
       </jaxws:properties>
       <jaxws:serviceFactory>
<bean class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">

gdprao wrote:
Hi,

I am trying CXF JSON web service. I am getting JSON string output fine. But when I tried to access my service
http://localhost:8080/myapp/services/json/custStatus it is displaying the
following error in browser (Firefox source).

<parsererror
xmlns="http://www.mozilla.org/newlayout/xml/parsererror.xml";>XML Parsing
Error: not well-formed
Location: http://localhost:8080/myapp/services/json/custStatus
Line Number 1, Column
1:<sourcetext>{"myns.custStatus":{"id":"602569","custName":"test","custStatus":"Active"}}
^</sourcetext></parsererror>

In IE, I have following error: "Invalid at the top level of the document.
Error processing resource". The JSON output is fine.
I am using <entry key="Content-Type" value="text/plain" /> in properties Map
of the JaxWsServiceFactoryBean alongwith Jettison
Map entries. Any help is appreciated.

Thanks,
Durga

Reply via email to