You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by gdprao <gd...@yahoo.com> on 2007/10/02 15:22:00 UTC
JSON output format problem
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
--
View this message in context: http://www.nabble.com/JSON-output-format-problem-tf4554816.html#a12998684
Sent from the cxf-user mailing list archive at Nabble.com.
Re: JSON output format problem
Posted by gdprao <gd...@yahoo.com>.
Thanks a lot. I tried this configuration and it perfectly worked.
Dale Peakall-2 wrote:
>
> 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
>>
>
>
>
--
View this message in context: http://www.nabble.com/JSON-output-format-problem-tf4554816.html#a12999360
Sent from the cxf-user mailing list archive at Nabble.com.
Re: JSON output format problem
Posted by Dale Peakall <d....@oclcpica.org>.
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
>