You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Penmatsa, Vinay" <vi...@sap.com> on 2012/06/13 21:58:43 UTC
MessageBodyReader/Writer for MultivaluedMap
>From documentation in http://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-MessageBodyProviders:
"By default, CXF supports String, byte[], InputStream, Reader, File, JAXP Source, JAX-RS StreamingOutput, JAXB-annotated types with application/xml, text/xml and application/json formats as well as JAXBElement (see below). JAX-RS MultivaluedMap is also supported for form contents.
See also the "Support for data bindings" section below."
I couldn't find a MessageBodyReader/Writer implementation for MultivaluedMap in CXF. How could I use this type?
In general, if I want to use a Map<String,String> in a REST POST, should I write readers/writers for the Map type or does CXF provide anything by default?
Thanks,
Vinay
Re: MessageBodyReader/Writer for MultivaluedMap
Posted by Sergey Beryozkin <sb...@gmail.com>.
On 13/06/12 20:58, Penmatsa, Vinay wrote:
> From documentation in http://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-MessageBodyProviders:
>
> "By default, CXF supports String, byte[], InputStream, Reader, File, JAXP Source, JAX-RS StreamingOutput, JAXB-annotated types with application/xml, text/xml and application/json formats as well as JAXBElement (see below). JAX-RS MultivaluedMap is also supported for form contents.
> See also the "Support for data bindings" section below."
>
> I couldn't find a MessageBodyReader/Writer implementation for MultivaluedMap in CXF. How could I use this type?
org.apache.cxf.jaxrs.provider.FormEncodingProvider manages
MultivaluedMap, it is enabled by default
> In general, if I want to use a Map<String,String> in a REST POST, should I write readers/writers for the Map type or does CXF provide anything by default?
>
Map<String, String> is not equivalent to MultivaluedMap<String, String>,
the latter is actually Map<String, List<String>>.
So yes, if you need to handle Map<String, String>, then add a provider
for it
Cheers, Sergey
> Thanks,
> Vinay
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com
Re: MessageBodyReader/Writer for MultivaluedMap
Posted by Glen Mazza <gm...@talend.com>.
Not sure if this answers your question, but here:
https://github.com/gmazza/jersey-samples-on-cxf/blob/master/simple-servlet/src/main/java/com/sun/jersey/samples/servlet/resources/ResourceBean3.java#L130
(line 130-160) shows ways to work with MultivaluedMap within a REST
resource (at least with a @GET). A custom MessageBodyReader/Writer
wasn't needed in that case.
This was for the "simple-servlet" example listed here:
http://www.jroller.com/gmazza/entry/jersey_samples_on_cxf
HTH,
Glen
On 06/13/2012 03:58 PM, Penmatsa, Vinay wrote:
> From documentation in http://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-MessageBodyProviders:
>
> "By default, CXF supports String, byte[], InputStream, Reader, File, JAXP Source, JAX-RS StreamingOutput, JAXB-annotated types with application/xml, text/xml and application/json formats as well as JAXBElement (see below). JAX-RS MultivaluedMap is also supported for form contents.
> See also the "Support for data bindings" section below."
>
> I couldn't find a MessageBodyReader/Writer implementation for MultivaluedMap in CXF. How could I use this type?
> In general, if I want to use a Map<String,String> in a REST POST, should I write readers/writers for the Map type or does CXF provide anything by default?
>
> Thanks,
> Vinay
>
--
Glen Mazza
Talend Community Coders
coders.talend.com
blog: www.jroller.com/gmazza