You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Vjacheslav V. Borisov" <sl...@gmail.com> on 2014/09/05 12:28:57 UTC

Custom provider application/x-www-form-urlencoded to bean (jaxb)

Hi !

Currently in apache cxf possible to do basic bean injection:
    @POST
    @Consumes("application/x-www-form-urlencoded")
    public Response createProcessInstanceForm(@FormParam("")
CreateProcessInstanceRequest createprocessinstancerequest) {
}

Can I write provider to realise custom form POST
(application/x-www-form-urlencoded) or
GET (query param) to bean injection or with intemediate step
application/x-www-form-urlencoded -> xml -> bean (jaxb unmarashall) )?

Re: Custom provider application/x-www-form-urlencoded to bean (jaxb)

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 05/09/14 11:28, Vjacheslav V. Borisov wrote:
> Hi !
>
> Currently in apache cxf possible to do basic bean injection:
>      @POST
>      @Consumes("application/x-www-form-urlencoded")
>      public Response createProcessInstanceForm(@FormParam("")
> CreateProcessInstanceRequest createprocessinstancerequest) {
> }
>
> Can I write provider to realise custom form POST
> (application/x-www-form-urlencoded) or
> GET (query param) to bean injection or with intemediate step
> application/x-www-form-urlencoded -> xml -> bean (jaxb unmarashall) )?
>
You can use JAX-RS 2.0 @BeanParam annotation with a bean whose 
individual properties are annotated with @FormParam. Or write a custom 
MessageBodyReader which takes a form payload and populates a bean.
Another option is to use MultivaluedMap to capture all the form 
properties in a map

HTH, Sergey