cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Diephouse" <...@envoisolutions.com>
Subject Re: returning xml from REST based web service
Date Tue, 14 Aug 2007 04:25:07 GMT
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 <dave.kallstrom@gmail.com> wrote:
>
> However with wrappedmode="false" my incoming parameter is null.
> Back to square one.
>
> On 8/13/07, Dave Kallstrom <dave.kallstrom@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 <dave.kallstrom@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">&lt;?xml version="
1.0"
> > > > > encoding="UTF-8" ?>&#xd;
> > > > > &lt;add>&lt;doc>&#xd;
> > > > > &lt;field name="id">1&lt;/field>&#xd;
> > > > > &lt;field name="filename"> beaver.psd&lt;/field>&#xd;
> > > > > &lt;field
> > > > name="releaseDate">2007-08-10T10:00:20:070Z&lt;/field>&#xd;
> > > > > &lt;field
> name="dateAdded">2007-08-10T10:00:20:070Z&lt;/field>&#xd;
> > > > >
> > > > > &lt;field
> > > > name="dateUpdated">2007-08-10T10:00:20:070Z&lt;/field>&#xd;
> > > > > &lt;/doc>&lt;/add>&#xd;
> > > > > </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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message