You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Dave Kallstrom <da...@gmail.com> on 2007/08/10 20:25:04 UTC
returning xml from REST based web service
I am tring to return a snippet of xml as a string from a cxf/rest based web
service method. How do I prevent cxf from marking it up.
Here is what is supposed to be returned
<?xml version="1.0" encoding="UTF-8" ?>
<add><doc>
<field name="id">1</field>
<field name="filename">filename.psd</field>
<field name="releaseDate">2007-08-10T10:00:20:070Z</field>
<field name="dateAdded">2007-08-10T10:00:20:070Z</field>
<field name="dateUpdated">2007-08-10T10:00:20:070Z</field>
</doc></add>
Here is the response from cxf
<ns2:getDocumentsResponse
xmlns:ns2="http://myservice.webservices"><?xml version="1.0"
encoding="UTF-8" ?>
<add><doc>
<field name="id">1</field>
<field name="filename">beaver.psd</field>
<field name="releaseDate">2007-08-10T10:00:20:070Z</field>
<field name="dateAdded">2007-08-10T10:00:20:070Z</field>
<field name="dateUpdated">2007-08-10T10:00:20:070Z</field>
</doc></add>
</ns2:getDocumentsResponse>
--
Dave Kallstrom
Re: returning xml from REST based web service
Posted by Dan Diephouse <da...@envoisolutions.com>.
If you do wrapped=false, then the {hello} gets mapped to a property on your
first request parameter. I.e. you would need to do something like this:
@Get
@HttpResource(location="/greetings/{hello}")
@WebMethod(operationName="GetHello")
public abstract org.w3c.dom.DocumentgetHello(@WebParam(name="hello") String
hello);
I did see a commit the other day which may fix your NPE problem. I don't
think the http binding code was written with the thought of using xsd:any,
so I going to guess that that is whats triggering the bug in
IriDecoderHelper :-(.
- Dan
On 8/13/07, Dave Kallstrom <da...@gmail.com> wrote:
>
> However with wrappedmode="false" my incoming parameter is null.
> Back to square one.
>
> On 8/13/07, Dave Kallstrom <da...@gmail.com> wrote:
> >
> > Me and my feeble mind just got it working... Dumped the wrapped
> > mode="false"
> > Now my xml is returns without any markup.
> > <jaxws:endpoint id="Hello" implementor="com.widen.HelloWorldImpl"
> > bindingUri=" http://apache.org/cxf/binding/http" address="/hello" >
> > <jaxws:serviceFactory>
> > <bean class="
> > org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean ">
> > <property name="dataBinding" ref="aegisDataBinding"/>
> > <property name="serviceConfigurations">
> > <list merge="false">
> > <ref bean="jaxConfig"/>
> > <ref bean="aegisConfig"/>
> > <ref bean="defaultConfig"/>
> > </list>
> > </property>
> > </bean>
> > </jaxws:serviceFactory>
> > </jaxws:endpoint>
> > <bean id="aegisDataBinding" class="
> > org.apache.cxf.aegis.databinding.AegisDatabinding "/>
> >
> > On 8/13/07, Dave Kallstrom <da...@gmail.com> wrote:
> > >
> > > Okay,
> > > Now I am getting a NPE before my method gets called.
> > > INFO: Interceptor has thrown exception, unwinding now
> > > java.lang.NullPointerException
> > > at org.apache.cxf.binding.http.IriDecoderHelper.buildDocument (
> > > IriDecoderHelper.java:222)
> > > I noticed someone else has had similar problems. Is there a
> resolution?
> > >
> http://mail-archives.apache.org/mod_mbox/incubator-cxf-user/200707.mbox/%3C468E10A5.6000708@iona.com%3E
> > >
> > > Here are the particulars.
> > > @Get
> > > @HttpResource(location="/greetings/{hello}")
> > > @WebMethod(operationName="GetHello")
> > > public abstract org.w3c.dom.DocumentgetHello(@WebParam(name="GetHello")GetHello
> getHello);
> > > and my cxf.xml file looks like this
> > > <beans xmlns="http://www.springframework.org/schema/beans "
> > > xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
> > > xmlns:jaxws="http://cxf.apache.org/jaxws"
> > > xmlns:xsd=" http://www.w3.org/2001/XMLSchema"
> > > xsi:schemaLocation="
> > > http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
> > > http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd ">
> > >
> > > <import resource="classpath:META-INF/cxf/cxf.xml"/>
> > > <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
> > > <import resource="classpath:META-INF/cxf/cxf-
> > > extension-http-binding.xml"/>
> > >
> > > <bean id="jaxConfig" class="
> > > org.apache.cxf.jaxws.support.JaxWsServiceConfiguration"/>
> > > <bean id="aegisConfig" class="
> > > org.apache.cxf.aegis.databinding.AegisServiceConfiguration"/>
> > > <bean id="aegisBean" class="
> > > org.apache.cxf.aegis.databinding.AegisDatabinding"/>
> > > <bean id="defaultConfig" class="
> > > org.apache.cxf.service.factory.DefaultServiceConfiguration"/>
> > >
> > > <jaxws:endpoint id="Hello" implementor="com.widen.HelloWorldImpl"
> > > bindingUri=" http://apache.org/cxf/binding/http" address="/hello" >
> > > <jaxws:serviceFactory>
> > > <bean class="
> > > org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
> > > <property name="wrapped" value="false" />
> > > <property name="dataBinding" ref="aegisDataBinding"/>
> > > <property name="serviceConfigurations">
> > > <list merge="false">
> > > <ref bean="aegisConfig"/>
> > > <ref bean="defaultConfig"/>
> > > <ref bean="jaxConfig"/>
> > > </list>
> > > </property>
> > > </bean>
> > > </jaxws:serviceFactory>
> > > </jaxws:endpoint>
> > > <bean id="aegisDataBinding" class="
> > > org.apache.cxf.aegis.databinding.AegisDatabinding"/>
> > > </beans>
> > >
> > > On 8/10/07, Dan Diephouse <dan@envoisolutions.com > wrote:
> > > >
> > > > JAXB will encode any strings that you return. If you want to return
> an
> > > > xml
> > > > document directly from a RESTful service you'd have to use a
> different
> > > > databinding. If you use the Aegis databinding you can return
> > > > javax.xml.transform.Source objects or or org.w3c.dom.Documents.
> > > > http://cwiki.apache.org/CXF20DOC/aegis-databinding.html. Strings
> will
> > > > still
> > > > be encoded.
> > > >
> > > > Hope that helps,
> > > > - Dan
> > > >
> > > > On 8/10/07, Dave Kallstrom < dave.kallstrom@gmail.com > wrote:
> > > > >
> > > > > I am tring to return a snippet of xml as a string from a cxf/rest
> > > > based
> > > > > web
> > > > > service method. How do I prevent cxf from marking it up.
> > > > > Here is what is supposed to be returned
> > > > > <?xml version="1.0" encoding="UTF-8" ?>
> > > > > <add><doc>
> > > > > <field name="id">1</field>
> > > > > <field name="filename">filename.psd </field>
> > > > > <field name="releaseDate">2007-08-10T10:00:20:070Z</field>
> > > > > <field name="dateAdded">2007-08-10T10:00:20:070Z</field>
> > > > > <field name="dateUpdated">2007-08-10T10:00:20:070Z</field>
> > > > > </doc></add>
> > > > > Here is the response from cxf
> > > > >
> > > > > <ns2:getDocumentsResponse
> > > > > xmlns:ns2=" http://myservice.webservices"><?xml version=" 1.0"
> > > > > encoding="UTF-8" ?>
> > > > > <add><doc>
> > > > > <field name="id">1</field>
> > > > > <field name="filename"> beaver.psd</field>
> > > > > <field
> > > > name="releaseDate">2007-08-10T10:00:20:070Z</field>
> > > > > <field
> name="dateAdded">2007-08-10T10:00:20:070Z</field>
> > > > >
> > > > > <field
> > > > name="dateUpdated">2007-08-10T10:00:20:070Z</field>
> > > > > </doc></add>
> > > > > </ns2:getDocumentsResponse>
> > > > >
> > > > >
> > > > > --
> > > > >
> > > > > Dave Kallstrom
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Dan Diephouse
> > > > Envoi Solutions
> > > > http://envoisolutions.com | http://netzooid.com/blog
> > > >
> > >
> > >
> > >
> > > --
> > > Dave Kallstrom
> >
> >
> >
> >
> > --
> > Dave Kallstrom
>
>
>
>
> --
> Dave Kallstrom
>
--
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog
Re: returning xml from REST based web service
Posted by Brad Harper <br...@gmail.com>.
I have the same issue...
On 8/13/07, Dave Kallstrom <da...@gmail.com> wrote:
>
> However with wrappedmode="false" my incoming parameter is null.
> Back to square one.
>
>
RE: returning xml from REST based web service
Posted by "Liu, Jervis" <jl...@iona.com>.
Hi Dave, please note your XML snippet that is defined as XSD:string will always be encoded no matter with JAXB binding or Aegis binding. A string within an XML document has to be encoded. One workaround is to redesign your schema, give your xml snippet a concrete schema type instead of xsd:string, or use xsd:any. But to be honest, I havent tried xsd:any by myself, not sure if it works or not. If you are 100% sure you do want to use xsd:string to represent your xml document, you should do the decoding on the client side, there are many utils can do this trivial task for you.
Cheers,
Jervis
> -----Original Message-----
> From: Dave Kallstrom [mailto:dave.kallstrom@gmail.com]
> Sent: 2007?8?14? 3:20
> To: cxf-user@incubator.apache.org
> Subject: Re: returning xml from REST based web service
>
>
> However with wrappedmode="false" my incoming parameter is null.
> Back to square one.
>
> On 8/13/07, Dave Kallstrom <da...@gmail.com> wrote:
> >
> > Me and my feeble mind just got it working... Dumped the wrapped
> > mode="false"
> > Now my xml is returns without any markup.
> > <jaxws:endpoint id="Hello" implementor="com.widen.HelloWorldImpl"
> > bindingUri=" http://apache.org/cxf/binding/http" address="/hello" >
> > <jaxws:serviceFactory>
> > <bean class="
> > org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean ">
> > <property name="dataBinding" ref="aegisDataBinding"/>
> > <property name="serviceConfigurations">
> > <list merge="false">
> > <ref bean="jaxConfig"/>
> > <ref bean="aegisConfig"/>
> > <ref bean="defaultConfig"/>
> > </list>
> > </property>
> > </bean>
> > </jaxws:serviceFactory>
> > </jaxws:endpoint>
> > <bean id="aegisDataBinding" class="
> > org.apache.cxf.aegis.databinding.AegisDatabinding "/>
> >
> > On 8/13/07, Dave Kallstrom <da...@gmail.com> wrote:
> > >
> > > Okay,
> > > Now I am getting a NPE before my method gets called.
> > > INFO: Interceptor has thrown exception, unwinding now
> > > java.lang.NullPointerException
> > > at
> org.apache.cxf.binding.http.IriDecoderHelper.buildDocument (
> > > IriDecoderHelper.java:222)
> > > I noticed someone else has had similar problems. Is there
> a resolution?
> > >
> http://mail-archives.apache.org/mod_mbox/incubator-cxf-user/20
0707.mbox/%3C468E10A5.6000708@iona.com%3E
> > >
> > > Here are the particulars.
> > > @Get
> > > @HttpResource(location="/greetings/{hello}")
> > > @WebMethod(operationName="GetHello")
> > > public abstract
> org.w3c.dom.DocumentgetHello(@WebParam(name="GetHello")GetHell
> o getHello);
> > > and my cxf.xml file looks like this
> > > <beans xmlns="http://www.springframework.org/schema/beans "
> > > xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
> > > xmlns:jaxws="http://cxf.apache.org/jaxws"
> > > xmlns:xsd=" http://www.w3.org/2001/XMLSchema"
> > > xsi:schemaLocation="
> > > http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
> > > http://cxf.apache.org/jaxws
> http://cxf.apache.org/schemas/jaxws.xsd ">
> > >
> > > <import resource="classpath:META-INF/cxf/cxf.xml"/>
> > > <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
> > > <import resource="classpath:META-INF/cxf/cxf-
> > > extension-http-binding.xml"/>
> > >
> > > <bean id="jaxConfig" class="
> > > org.apache.cxf.jaxws.support.JaxWsServiceConfiguration"/>
> > > <bean id="aegisConfig" class="
> > > org.apache.cxf.aegis.databinding.AegisServiceConfiguration"/>
> > > <bean id="aegisBean" class="
> > > org.apache.cxf.aegis.databinding.AegisDatabinding"/>
> > > <bean id="defaultConfig" class="
> > > org.apache.cxf.service.factory.DefaultServiceConfiguration"/>
> > >
> > > <jaxws:endpoint id="Hello"
> implementor="com.widen.HelloWorldImpl"
> > > bindingUri=" http://apache.org/cxf/binding/http"
> address="/hello" >
> > > <jaxws:serviceFactory>
> > > <bean class="
> > > org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
> > > <property name="wrapped" value="false" />
> > > <property name="dataBinding" ref="aegisDataBinding"/>
> > > <property name="serviceConfigurations">
> > > <list merge="false">
> > > <ref bean="aegisConfig"/>
> > > <ref bean="defaultConfig"/>
> > > <ref bean="jaxConfig"/>
> > > </list>
> > > </property>
> > > </bean>
> > > </jaxws:serviceFactory>
> > > </jaxws:endpoint>
> > > <bean id="aegisDataBinding" class="
> > > org.apache.cxf.aegis.databinding.AegisDatabinding"/>
> > > </beans>
> > >
> > > On 8/10/07, Dan Diephouse <dan@envoisolutions.com > wrote:
> > > >
> > > > JAXB will encode any strings that you return. If you
> want to return an
> > > > xml
> > > > document directly from a RESTful service you'd have to
> use a different
> > > > databinding. If you use the Aegis databinding you can return
> > > > javax.xml.transform.Source objects or or org.w3c.dom.Documents.
> > > >
> http://cwiki.apache.org/CXF20DOC/aegis-databinding.html. Strings will
> > > > still
> > > > be encoded.
> > > >
> > > > Hope that helps,
> > > > - Dan
> > > >
> > > > On 8/10/07, Dave Kallstrom < dave.kallstrom@gmail.com > wrote:
> > > > >
> > > > > I am tring to return a snippet of xml as a string
> from a cxf/rest
> > > > based
> > > > > web
> > > > > service method. How do I prevent cxf from marking it up.
> > > > > Here is what is supposed to be returned
> > > > > <?xml version="1.0" encoding="UTF-8" ?>
> > > > > <add><doc>
> > > > > <field name="id">1</field>
> > > > > <field name="filename">filename.psd </field>
> > > > > <field name="releaseDate">2007-08-10T10:00:20:070Z</field>
> > > > > <field name="dateAdded">2007-08-10T10:00:20:070Z</field>
> > > > > <field name="dateUpdated">2007-08-10T10:00:20:070Z</field>
> > > > > </doc></add>
> > > > > Here is the response from cxf
> > > > >
> > > > > <ns2:getDocumentsResponse
> > > > > xmlns:ns2=" http://myservice.webservices"><?xml
> version=" 1.0"
> > > > > encoding="UTF-8" ?>
> > > > > <add><doc>
> > > > > <field name="id">1</field>
> > > > > <field name="filename"> beaver.psd</field>
> > > > > <field
> > > > name="releaseDate">2007-08-10T10:00:20:070Z</field>
> > > > > <field
> name="dateAdded">2007-08-10T10:00:20:070Z</field>
> > > > >
> > > > > <field
> > > > name="dateUpdated">2007-08-10T10:00:20:070Z</field>
> > > > > </doc></add>
> > > > > </ns2:getDocumentsResponse>
> > > > >
> > > > >
> > > > > --
> > > > >
> > > > > Dave Kallstrom
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Dan Diephouse
> > > > Envoi Solutions
> > > > http://envoisolutions.com | http://netzooid.com/blog
> > > >
> > >
> > >
> > >
> > > --
> > > Dave Kallstrom
> >
> >
> >
> >
> > --
> > Dave Kallstrom
>
>
>
>
> --
> Dave Kallstrom
>
----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
Re: returning xml from REST based web service
Posted by Dave Kallstrom <da...@gmail.com>.
However with wrappedmode="false" my incoming parameter is null.
Back to square one.
On 8/13/07, Dave Kallstrom <da...@gmail.com> wrote:
>
> Me and my feeble mind just got it working... Dumped the wrapped
> mode="false"
> Now my xml is returns without any markup.
> <jaxws:endpoint id="Hello" implementor="com.widen.HelloWorldImpl"
> bindingUri=" http://apache.org/cxf/binding/http" address="/hello" >
> <jaxws:serviceFactory>
> <bean class="
> org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean ">
> <property name="dataBinding" ref="aegisDataBinding"/>
> <property name="serviceConfigurations">
> <list merge="false">
> <ref bean="jaxConfig"/>
> <ref bean="aegisConfig"/>
> <ref bean="defaultConfig"/>
> </list>
> </property>
> </bean>
> </jaxws:serviceFactory>
> </jaxws:endpoint>
> <bean id="aegisDataBinding" class="
> org.apache.cxf.aegis.databinding.AegisDatabinding "/>
>
> On 8/13/07, Dave Kallstrom <da...@gmail.com> wrote:
> >
> > Okay,
> > Now I am getting a NPE before my method gets called.
> > INFO: Interceptor has thrown exception, unwinding now
> > java.lang.NullPointerException
> > at org.apache.cxf.binding.http.IriDecoderHelper.buildDocument (
> > IriDecoderHelper.java:222)
> > I noticed someone else has had similar problems. Is there a resolution?
> > http://mail-archives.apache.org/mod_mbox/incubator-cxf-user/200707.mbox/%3C468E10A5.6000708@iona.com%3E
> >
> > Here are the particulars.
> > @Get
> > @HttpResource(location="/greetings/{hello}")
> > @WebMethod(operationName="GetHello")
> > public abstract org.w3c.dom.DocumentgetHello(@WebParam(name="GetHello")GetHello getHello);
> > and my cxf.xml file looks like this
> > <beans xmlns="http://www.springframework.org/schema/beans "
> > xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
> > xmlns:jaxws="http://cxf.apache.org/jaxws"
> > xmlns:xsd=" http://www.w3.org/2001/XMLSchema"
> > xsi:schemaLocation="
> > http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
> > http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd ">
> >
> > <import resource="classpath:META-INF/cxf/cxf.xml"/>
> > <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
> > <import resource="classpath:META-INF/cxf/cxf-
> > extension-http-binding.xml"/>
> >
> > <bean id="jaxConfig" class="
> > org.apache.cxf.jaxws.support.JaxWsServiceConfiguration"/>
> > <bean id="aegisConfig" class="
> > org.apache.cxf.aegis.databinding.AegisServiceConfiguration"/>
> > <bean id="aegisBean" class="
> > org.apache.cxf.aegis.databinding.AegisDatabinding"/>
> > <bean id="defaultConfig" class="
> > org.apache.cxf.service.factory.DefaultServiceConfiguration"/>
> >
> > <jaxws:endpoint id="Hello" implementor="com.widen.HelloWorldImpl"
> > bindingUri=" http://apache.org/cxf/binding/http" address="/hello" >
> > <jaxws:serviceFactory>
> > <bean class="
> > org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
> > <property name="wrapped" value="false" />
> > <property name="dataBinding" ref="aegisDataBinding"/>
> > <property name="serviceConfigurations">
> > <list merge="false">
> > <ref bean="aegisConfig"/>
> > <ref bean="defaultConfig"/>
> > <ref bean="jaxConfig"/>
> > </list>
> > </property>
> > </bean>
> > </jaxws:serviceFactory>
> > </jaxws:endpoint>
> > <bean id="aegisDataBinding" class="
> > org.apache.cxf.aegis.databinding.AegisDatabinding"/>
> > </beans>
> >
> > On 8/10/07, Dan Diephouse <dan@envoisolutions.com > wrote:
> > >
> > > JAXB will encode any strings that you return. If you want to return an
> > > xml
> > > document directly from a RESTful service you'd have to use a different
> > > databinding. If you use the Aegis databinding you can return
> > > javax.xml.transform.Source objects or or org.w3c.dom.Documents.
> > > http://cwiki.apache.org/CXF20DOC/aegis-databinding.html. Strings will
> > > still
> > > be encoded.
> > >
> > > Hope that helps,
> > > - Dan
> > >
> > > On 8/10/07, Dave Kallstrom < dave.kallstrom@gmail.com > wrote:
> > > >
> > > > I am tring to return a snippet of xml as a string from a cxf/rest
> > > based
> > > > web
> > > > service method. How do I prevent cxf from marking it up.
> > > > Here is what is supposed to be returned
> > > > <?xml version="1.0" encoding="UTF-8" ?>
> > > > <add><doc>
> > > > <field name="id">1</field>
> > > > <field name="filename">filename.psd </field>
> > > > <field name="releaseDate">2007-08-10T10:00:20:070Z</field>
> > > > <field name="dateAdded">2007-08-10T10:00:20:070Z</field>
> > > > <field name="dateUpdated">2007-08-10T10:00:20:070Z</field>
> > > > </doc></add>
> > > > Here is the response from cxf
> > > >
> > > > <ns2:getDocumentsResponse
> > > > xmlns:ns2=" http://myservice.webservices"><?xml version=" 1.0"
> > > > encoding="UTF-8" ?>
> > > > <add><doc>
> > > > <field name="id">1</field>
> > > > <field name="filename"> beaver.psd</field>
> > > > <field
> > > name="releaseDate">2007-08-10T10:00:20:070Z</field>
> > > > <field name="dateAdded">2007-08-10T10:00:20:070Z</field>
> > > >
> > > > <field
> > > name="dateUpdated">2007-08-10T10:00:20:070Z</field>
> > > > </doc></add>
> > > > </ns2:getDocumentsResponse>
> > > >
> > > >
> > > > --
> > > >
> > > > Dave Kallstrom
> > > >
> > >
> > >
> > >
> > > --
> > > Dan Diephouse
> > > Envoi Solutions
> > > http://envoisolutions.com | http://netzooid.com/blog
> > >
> >
> >
> >
> > --
> > Dave Kallstrom
>
>
>
>
> --
> Dave Kallstrom
--
Dave Kallstrom
Re: returning xml from REST based web service
Posted by Dave Kallstrom <da...@gmail.com>.
Me and my feeble mind just got it working... Dumped the wrapped mode="false"
Now my xml is returns without any markup.
<jaxws:endpoint id="Hello" implementor="com.widen.HelloWorldImpl"
bindingUri="http://apache.org/cxf/binding/http" address="/hello" >
<jaxws:serviceFactory>
<bean class="
org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
<property name="dataBinding" ref="aegisDataBinding"/>
<property name="serviceConfigurations">
<list merge="false">
<ref bean="jaxConfig"/>
<ref bean="aegisConfig"/>
<ref bean="defaultConfig"/>
</list>
</property>
</bean>
</jaxws:serviceFactory>
</jaxws:endpoint>
<bean id="aegisDataBinding" class="
org.apache.cxf.aegis.databinding.AegisDatabinding"/>
On 8/13/07, Dave Kallstrom <da...@gmail.com> wrote:
>
> Okay,
> Now I am getting a NPE before my method gets called.
> INFO: Interceptor has thrown exception, unwinding now
> java.lang.NullPointerException
> at org.apache.cxf.binding.http.IriDecoderHelper.buildDocument(
> IriDecoderHelper.java:222)
> I noticed someone else has had similar problems. Is there a resolution?
> http://mail-archives.apache.org/mod_mbox/incubator-cxf-user/200707.mbox/%3C468E10A5.6000708@iona.com%3E
>
> Here are the particulars.
> @Get
> @HttpResource(location="/greetings/{hello}")
> @WebMethod(operationName="GetHello")
> public abstract org.w3c.dom.DocumentgetHello(@WebParam(name="GetHello")GetHello getHello);
> and my cxf.xml file looks like this
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
> xmlns:jaxws="http://cxf.apache.org/jaxws"
> xmlns:xsd=" http://www.w3.org/2001/XMLSchema"
> xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
> http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd ">
>
> <import resource="classpath:META-INF/cxf/cxf.xml"/>
> <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
> <import resource="classpath:META-INF/cxf/cxf-
> extension-http-binding.xml"/>
>
> <bean id="jaxConfig" class="
> org.apache.cxf.jaxws.support.JaxWsServiceConfiguration"/>
> <bean id="aegisConfig" class="
> org.apache.cxf.aegis.databinding.AegisServiceConfiguration"/>
> <bean id="aegisBean" class="
> org.apache.cxf.aegis.databinding.AegisDatabinding"/>
> <bean id="defaultConfig" class="
> org.apache.cxf.service.factory.DefaultServiceConfiguration"/>
>
> <jaxws:endpoint id="Hello" implementor="com.widen.HelloWorldImpl"
> bindingUri=" http://apache.org/cxf/binding/http" address="/hello" >
> <jaxws:serviceFactory>
> <bean class="
> org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
> <property name="wrapped" value="false" />
> <property name="dataBinding" ref="aegisDataBinding"/>
> <property name="serviceConfigurations">
> <list merge="false">
> <ref bean="aegisConfig"/>
> <ref bean="defaultConfig"/>
> <ref bean="jaxConfig"/>
> </list>
> </property>
> </bean>
> </jaxws:serviceFactory>
> </jaxws:endpoint>
> <bean id="aegisDataBinding" class="
> org.apache.cxf.aegis.databinding.AegisDatabinding"/>
> </beans>
>
> On 8/10/07, Dan Diephouse <dan@envoisolutions.com > wrote:
> >
> > JAXB will encode any strings that you return. If you want to return an
> > xml
> > document directly from a RESTful service you'd have to use a different
> > databinding. If you use the Aegis databinding you can return
> > javax.xml.transform.Source objects or or org.w3c.dom.Documents.
> > http://cwiki.apache.org/CXF20DOC/aegis-databinding.html. Strings will
> > still
> > be encoded.
> >
> > Hope that helps,
> > - Dan
> >
> > On 8/10/07, Dave Kallstrom <dave.kallstrom@gmail.com > wrote:
> > >
> > > I am tring to return a snippet of xml as a string from a cxf/rest
> > based
> > > web
> > > service method. How do I prevent cxf from marking it up.
> > > Here is what is supposed to be returned
> > > <?xml version="1.0" encoding="UTF-8" ?>
> > > <add><doc>
> > > <field name="id">1</field>
> > > <field name="filename">filename.psd </field>
> > > <field name="releaseDate">2007-08-10T10:00:20:070Z</field>
> > > <field name="dateAdded">2007-08-10T10:00:20:070Z</field>
> > > <field name="dateUpdated">2007-08-10T10:00:20:070Z</field>
> > > </doc></add>
> > > Here is the response from cxf
> > >
> > > <ns2:getDocumentsResponse
> > > xmlns:ns2="http://myservice.webservices"><?xml version=" 1.0"
> > > encoding="UTF-8" ?>
> > > <add><doc>
> > > <field name="id">1</field>
> > > <field name="filename"> beaver.psd</field>
> > > <field name="releaseDate">2007-08-10T10:00:20:070Z</field>
> > > <field name="dateAdded">2007-08-10T10:00:20:070Z</field>
> > >
> > > <field name="dateUpdated">2007-08-10T10:00:20:070Z</field>
> > > </doc></add>
> > > </ns2:getDocumentsResponse>
> > >
> > >
> > > --
> > >
> > > Dave Kallstrom
> > >
> >
> >
> >
> > --
> > Dan Diephouse
> > Envoi Solutions
> > http://envoisolutions.com | http://netzooid.com/blog
> >
>
>
>
> --
> Dave Kallstrom
--
Dave Kallstrom
Re: returning xml from REST based web service
Posted by Dave Kallstrom <da...@gmail.com>.
Okay,
Now I am getting a NPE before my method gets called.
INFO: Interceptor has thrown exception, unwinding now
java.lang.NullPointerException
at org.apache.cxf.binding.http.IriDecoderHelper.buildDocument(
IriDecoderHelper.java:222)
I noticed someone else has had similar problems. Is there a resolution?
http://mail-archives.apache.org/mod_mbox/incubator-cxf-user/200707.mbox/%3C468E10A5.6000708@iona.com%3E
Here are the particulars.
@Get
@HttpResource(location="/greetings/{hello}")
@WebMethod(operationName="GetHello")
public abstract
org.w3c.dom.DocumentgetHello(@WebParam(name="GetHello")GetHello
getHello);
and my cxf.xml file looks like this
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd ">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<import resource="classpath:META-INF/cxf/cxf-
extension-http-binding.xml"/>
<bean id="jaxConfig" class="
org.apache.cxf.jaxws.support.JaxWsServiceConfiguration"/>
<bean id="aegisConfig" class="
org.apache.cxf.aegis.databinding.AegisServiceConfiguration"/>
<bean id="aegisBean" class="
org.apache.cxf.aegis.databinding.AegisDatabinding"/>
<bean id="defaultConfig" class="
org.apache.cxf.service.factory.DefaultServiceConfiguration"/>
<jaxws:endpoint id="Hello" implementor="com.widen.HelloWorldImpl"
bindingUri="http://apache.org/cxf/binding/http" address="/hello" >
<jaxws:serviceFactory>
<bean class="
org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
<property name="wrapped" value="false" />
<property name="dataBinding" ref="aegisDataBinding"/>
<property name="serviceConfigurations">
<list merge="false">
<ref bean="aegisConfig"/>
<ref bean="defaultConfig"/>
<ref bean="jaxConfig"/>
</list>
</property>
</bean>
</jaxws:serviceFactory>
</jaxws:endpoint>
<bean id="aegisDataBinding" class="
org.apache.cxf.aegis.databinding.AegisDatabinding"/>
</beans>
On 8/10/07, Dan Diephouse <da...@envoisolutions.com> wrote:
>
> JAXB will encode any strings that you return. If you want to return an xml
> document directly from a RESTful service you'd have to use a different
> databinding. If you use the Aegis databinding you can return
> javax.xml.transform.Source objects or or org.w3c.dom.Documents.
> http://cwiki.apache.org/CXF20DOC/aegis-databinding.html. Strings will
> still
> be encoded.
>
> Hope that helps,
> - Dan
>
> On 8/10/07, Dave Kallstrom <da...@gmail.com> wrote:
> >
> > I am tring to return a snippet of xml as a string from a cxf/rest based
> > web
> > service method. How do I prevent cxf from marking it up.
> > Here is what is supposed to be returned
> > <?xml version="1.0" encoding="UTF-8" ?>
> > <add><doc>
> > <field name="id">1</field>
> > <field name="filename">filename.psd</field>
> > <field name="releaseDate">2007-08-10T10:00:20:070Z</field>
> > <field name="dateAdded">2007-08-10T10:00:20:070Z</field>
> > <field name="dateUpdated">2007-08-10T10:00:20:070Z</field>
> > </doc></add>
> > Here is the response from cxf
> >
> > <ns2:getDocumentsResponse
> > xmlns:ns2="http://myservice.webservices"><?xml version="1.0"
> > encoding="UTF-8" ?>
> > <add><doc>
> > <field name="id">1</field>
> > <field name="filename">beaver.psd</field>
> > <field name="releaseDate">2007-08-10T10:00:20:070Z</field>
> > <field name="dateAdded">2007-08-10T10:00:20:070Z</field>
> >
> > <field name="dateUpdated">2007-08-10T10:00:20:070Z</field>
> > </doc></add>
> > </ns2:getDocumentsResponse>
> >
> >
> > --
> >
> > Dave Kallstrom
> >
>
>
>
> --
> Dan Diephouse
> Envoi Solutions
> http://envoisolutions.com | http://netzooid.com/blog
>
--
Dave Kallstrom
Re: returning xml from REST based web service
Posted by Dan Diephouse <da...@envoisolutions.com>.
JAXB will encode any strings that you return. If you want to return an xml
document directly from a RESTful service you'd have to use a different
databinding. If you use the Aegis databinding you can return
javax.xml.transform.Source objects or or org.w3c.dom.Documents.
http://cwiki.apache.org/CXF20DOC/aegis-databinding.html. Strings will still
be encoded.
Hope that helps,
- Dan
On 8/10/07, Dave Kallstrom <da...@gmail.com> wrote:
>
> I am tring to return a snippet of xml as a string from a cxf/rest based
> web
> service method. How do I prevent cxf from marking it up.
> Here is what is supposed to be returned
> <?xml version="1.0" encoding="UTF-8" ?>
> <add><doc>
> <field name="id">1</field>
> <field name="filename">filename.psd</field>
> <field name="releaseDate">2007-08-10T10:00:20:070Z</field>
> <field name="dateAdded">2007-08-10T10:00:20:070Z</field>
> <field name="dateUpdated">2007-08-10T10:00:20:070Z</field>
> </doc></add>
> Here is the response from cxf
>
> <ns2:getDocumentsResponse
> xmlns:ns2="http://myservice.webservices"><?xml version="1.0"
> encoding="UTF-8" ?>
> <add><doc>
> <field name="id">1</field>
> <field name="filename">beaver.psd</field>
> <field name="releaseDate">2007-08-10T10:00:20:070Z</field>
> <field name="dateAdded">2007-08-10T10:00:20:070Z</field>
>
> <field name="dateUpdated">2007-08-10T10:00:20:070Z</field>
> </doc></add>
> </ns2:getDocumentsResponse>
>
>
> --
>
> Dave Kallstrom
>
--
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog
RE: returning xml from REST based web service
Posted by "Stanley, David" <Da...@iona.com>.
Hi Dave,
Here's one way of doing it (stax interceptor). I'd be interested to know if theres a cleaner way.
Just install the interceptor as follows:
ServerImpl svr = (ServerImpl) sf.create();
svr.getEndpoint().getOutInterceptors().add(new RailsOutInterceptor());
(This should work with a Rails ActiveResource client btw)
Regards
/Dave
-----Original Message-----
From: Dave Kallstrom [mailto:dave.kallstrom@gmail.com]
Sent: Friday, August 10, 2007 2:25 PM
To: cxf-user@incubator.apache.org
Subject: returning xml from REST based web service
I am tring to return a snippet of xml as a string from a cxf/rest based web
service method. How do I prevent cxf from marking it up.
Here is what is supposed to be returned
<?xml version="1.0" encoding="UTF-8" ?>
<add><doc>
<field name="id">1</field>
<field name="filename">filename.psd</field>
<field name="releaseDate">2007-08-10T10:00:20:070Z</field>
<field name="dateAdded">2007-08-10T10:00:20:070Z</field>
<field name="dateUpdated">2007-08-10T10:00:20:070Z</field>
</doc></add>
Here is the response from cxf
<ns2:getDocumentsResponse
xmlns:ns2="http://myservice.webservices"><?xml version="1.0"
encoding="UTF-8" ?>
<add><doc>
<field name="id">1</field>
<field name="filename">beaver.psd</field>
<field name="releaseDate">2007-08-10T10:00:20:070Z</field>
<field name="dateAdded">2007-08-10T10:00:20:070Z</field>
<field name="dateUpdated">2007-08-10T10:00:20:070Z</field>
</doc></add>
</ns2:getDocumentsResponse>
--
Dave Kallstrom