You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Dale Peakall <d....@oclcpica.org> on 2007/07/20 12:55:24 UTC
Configuring a JSON endpoint via Spring
I've been trying to add a JSON endpoint to my service by updating the
Spring configuration but with no success. The REST based version works
just fine, but the JSON version either: returns an empty-page for the
Mapped version or returns:
{"ns1:XMLFault":{"@xmlns":{"ns1":"http:\/\/cxf.apache.org\/bindings\/xformat"},"ns1:faultstring":{"@xmlns":{"ns1":"http:\/\/cxf.apache.org\/bindings\/xformat"},"$":"java.lang.NullPointerException"}}}
for the BadgerFish based version. In neither case is the Content-Type
header set. Any ideas where I'm going wrong?
Here are the relevant excerpts from my spring configuration.
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import
resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<jaxws:endpoint id="catalogRestWS"
implementor="#catalogService"
address="/xml/Catalog"
bindingUri="http://apache.org/cxf/binding/http">
<jaxws:serviceFactory>
<bean
class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
<property name="wrapped" value="true"/>
</bean>
</jaxws:serviceFactory>
</jaxws:endpoint>
<jaxws:endpoint id="catalogJsonWS"
implementor="#catalogService"
address="/json/Catalog"
bindingUri="http://apache.org/cxf/binding/http">
<jaxws:serviceFactory>
<bean
class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
<property name="wrapped" value="false"/>
<property name="properties">
<map>
<entry key="Content-Type" value="text/plain"/>
<entry>
<key><value>javax.xml.stream.XMLInputFactory</value></key>
<bean
class="org.codehaus.jettison.mapped.MappedXMLInputFactory">
<constructor-arg>
<map>
<entry
key="http://catalog.epv.oclc.org/" value="catalog"/>
<entry
key="http://impl.catalog.epv.oclc.org/" value="catalogimpl"/>
</map>
</constructor-arg>
</bean>
</entry>
<entry>
<key><value>javax.xml.stream.XMLOutputFactory</value></key>
<bean
class="org.codehaus.jettison.mapped.MappedXMLOutputFactory">
<constructor-arg>
<map>
<entry
key="http://catalog.epv.oclc.org/" value="catalog"/>
<entry
key="http://impl.catalog.epv.oclc.org/" value="catalogimpl"/>
</map>
</constructor-arg>
</bean>
</entry>
<!--
<entry>
<key><value>javax.xml.stream.XMLInputFactory</value></key>
<bean
class="org.codehaus.jettison.badgerfish.BadgerFishXMLInputFactory"/>
</entry>
<entry>
<key><value>javax.xml.stream.XMLOutputFactory</value></key>
<bean
class="org.codehaus.jettison.badgerfish.BadgerFishXMLOutputFactory"/>
</entry>
-->
</map>
</property>
</bean>
</jaxws:serviceFactory>
</jaxws:endpoint>
RE: Configuring a JSON endpoint via Spring
Posted by "Jiang, Ning (Willem)" <Ni...@iona.com>.
Hi
>From your fault message, I think you need add the below line in you spring application context.
<import resource="classpath:META-INF/cxf/cxf-extension-xml.xml"/>
Which include the cxf xformat binding for wiring the bus.
Willem
-----Original Message-----
From: Dale Peakall [mailto:d.peakall@oclcpica.org]
Sent: Fri 7/20/2007 18:55
To: cxf-user@incubator.apache.org
Subject: Configuring a JSON endpoint via Spring
I've been trying to add a JSON endpoint to my service by updating the
Spring configuration but with no success. The REST based version works
just fine, but the JSON version either: returns an empty-page for the
Mapped version or returns:
{"ns1:XMLFault":{"@xmlns":{"ns1":"http:\/\/cxf.apache.org\/bindings\/xformat"},"ns1:faultstring":{"@xmlns":{"ns1":"http:\/\/cxf.apache.org\/bindings\/xformat"},"$":"java.lang.NullPointerException"}}}
for the BadgerFish based version. In neither case is the Content-Type
header set. Any ideas where I'm going wrong?
Here are the relevant excerpts from my spring configuration.
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import
resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<jaxws:endpoint id="catalogRestWS"
implementor="#catalogService"
address="/xml/Catalog"
bindingUri="http://apache.org/cxf/binding/http">
<jaxws:serviceFactory>
<bean
class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
<property name="wrapped" value="true"/>
</bean>
</jaxws:serviceFactory>
</jaxws:endpoint>
<jaxws:endpoint id="catalogJsonWS"
implementor="#catalogService"
address="/json/Catalog"
bindingUri="http://apache.org/cxf/binding/http">
<jaxws:serviceFactory>
<bean
class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
<property name="wrapped" value="false"/>
<property name="properties">
<map>
<entry key="Content-Type" value="text/plain"/>
<entry>
<key><value>javax.xml.stream.XMLInputFactory</value></key>
<bean
class="org.codehaus.jettison.mapped.MappedXMLInputFactory">
<constructor-arg>
<map>
<entry
key="http://catalog.epv.oclc.org/" value="catalog"/>
<entry
key="http://impl.catalog.epv.oclc.org/" value="catalogimpl"/>
</map>
</constructor-arg>
</bean>
</entry>
<entry>
<key><value>javax.xml.stream.XMLOutputFactory</value></key>
<bean
class="org.codehaus.jettison.mapped.MappedXMLOutputFactory">
<constructor-arg>
<map>
<entry
key="http://catalog.epv.oclc.org/" value="catalog"/>
<entry
key="http://impl.catalog.epv.oclc.org/" value="catalogimpl"/>
</map>
</constructor-arg>
</bean>
</entry>
<!--
<entry>
<key><value>javax.xml.stream.XMLInputFactory</value></key>
<bean
class="org.codehaus.jettison.badgerfish.BadgerFishXMLInputFactory"/>
</entry>
<entry>
<key><value>javax.xml.stream.XMLOutputFactory</value></key>
<bean
class="org.codehaus.jettison.badgerfish.BadgerFishXMLOutputFactory"/>
</entry>
-->
</map>
</property>
</bean>
</jaxws:serviceFactory>
</jaxws:endpoint>