Firstly, it probably makes more sense to set wrapped style to false in your
case, otherwise you have to sent your post request with a wrapper. For example,
if your resource method is:
@Post
@HttpResource(location = "/books")
@WebResult(name = "book")
long addBook(@WebParam(name = "Book")
Book c);
With wrapped style equal to true, you need to send a request like below:
< addBook ><Book><id>124</id><name>CXF in Action</name></Book></addBook>
Once you set wrapped style to false, unfortunately you will run into another
problem. There is a limitation currently in CXF HTTP binding implementation
that it cannot deal with XmlSchemaSimpleType properly, thus the request cannot
be marshaled to a String properly (if someone is curious, the problematic code
is located in IriDecoderHelper.interopolateParams()). A workaround is to
receive a Book object, then you marshal the Book to a string by yourself.
@Post
@HttpResource(location = "/books")
@WebResult(name = "book")
long addBook(@WebParam(name = "Book")
Book c);
public long addBook(Book b) {
String input = b.toString();
....
}
Hope this helps,
Jervis
> -----Original Message-----
> From: Kamlesh [mailto:[EMAIL PROTECTED]
> Sent: 2008年1月13日 23:17
> To: [email protected]
> Subject: RE: Unable to get xml as tring in rest services
>
>
> Hi, Jarvis
>
> Thanks. All our applications are having XFIRE-JiBX combination. In our new
> applications, we want to use CXF. Since currently CXF don't support JiBX
> bindings, as interim solution, we want to receive payload as XML and do
> binding at application level. As soon as CXF supports JiBX ,we will switch
> CXF configrations to CXF-JiBX.
>
> I have successfully implemented JAX-WS services, where we send layload as
> xml inclosed in CDATA element and it works fine We also want to expose the
> same service using Rest where we can receive payload as string. In my
> configuration my method input param is string and when I post string, I
> think I should get string from CXF. What is wrong kindly help me undetstand.
>
> Regards
> Kamlesh
>
>
> Liu, Jervis wrote:
> >
> > You may want to check out the JSR-311 implementation in CXF, it is more
> > standard based [1].
> >
> > [1]. http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html
> >
> > Cheers,
> > Jervis
> >
> >> -----Original Message-----
> >> From: Kamlesh [mailto:[EMAIL PROTECTED]
> >> Sent: 2008年1月12日 7:02
> >> To: [email protected]
> >> Subject: Unable to get xml as tring in rest services
> >>
> >>
> >> Hi, All
> >>
> >> I have following rest service. When I post a request xml using wget, I
> >> get
> >> null string on my impl class. I want to recevice xml as string so that I
> >> can
> >> marshall the string using JiBX.
> >>
> >> @Post
> >> @HttpResource(location = "/requestHLTranscode")
> >> public String
> >> requestHLTranscode(@WebParam(name="requestXML")String
> >> requestXML);
> >>
> >> Configuration
> >> ==========
> >> <jaxws:endpoint id="transcodeservice_rest"
> >> implementor="#transcodeService"
> >> address="/TranscodeService_Rest"
> >> 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>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/Unable-to-get-xml-as-tring-in-rest-services-tp1476
> >> 7165p14767165.html
> >> Sent from the cxf-user mailing list archive at Nabble.com.
> >
> > ----------------------------
> > IONA Technologies PLC (registered in Ireland)
> > Registered Number: 171387
> > Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Unable-to-get-xml-as-tring-in-rest-services-tp1476
> 7165p14786966.html
> Sent from the cxf-user mailing list archive at Nabble.com.
----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland