If you give me a quick recipe to log what comes in over the wire to a JAX-RS endpoint, though, I'll do it and send it along.
On Sun, Oct 11, 2009 at 2:06 PM, Sergey Beryozkin <[email protected] > wrote: > > By the way, Benson, can you please post a sample request, as seen on the > wire > ? > I'd like to see if the JSON sequence is actually form-urlencoded ? > cheers, Sergey > > > Sergey Beryozkin wrote: > > > > Hi Benson > > > > AFAIK multipart/form-data is mainly used to submit files from the forms > > [1], though individual parts may contain > > "application/x-www-form-urlencoded" data, this is my interpretation at > > least and this is how I implemented the way multipart/form-data is > > handled. So it should really be : > > @Consumes("multipart/form-data") > > public Response addGazetteer(@FormParam("gazetter") String > gazetteer) > > { > > } > > > > in other words CXF FormProvider will not delegate to other providers > > (JAXB/JSON, etc) when dealing with "multipart/form-data"; perhaps it > > should ? > > > > It is MultipartProvider which deals with multipart/related, > > multipart/mixed, etc, which will delegate. It is this provider which will > > notice @Multipart(type = "application/json"). > > > > There's a couple of options. If you can actually afford specifying say > > multipart/mixed then it will work as expected. Another option is to > > register a simple RequestFilter impl which will change > multipart/form-data > > to say multipart/mixed. Finally you can do > > > > @Consumes("multipart/form-data") > > public Response addGazetteer(@FormParam("gazetter") Gazetter > > gazetteer) { > > } > > > > and register a ParameterHandler<Gazetter> which will use a JSONProvider > to > > convert a JSON sequence into Gazetter > > > > cheers, Sergey > > > > [1]http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2 > > > > > > bimargulies wrote: > >> > >> Oct 10, 2009 5:08:59 PM org.apache.cxf.jaxrs.utils.JAXRSUtils > >> readFromMessageBody > >> WARNING: .No message body reader found for request class : Gazetteer, > >> ContentType : > >> multipart/form-data;boundary=hxz8idwzzxgwwr7p0v1vregmn2wxnajqg0f_bxk6. > >> Oct 10, 2009 5:08:59 PM > >> org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse > >> WARNING: WebApplicationException has been caught : no cause is available > >> > >> And my function is: > >> > >> @POST > >> @Path("/gazetteer/new") > >> @Consumes("multipart/form-data") > >> public Response addGazetteer(@Multipart(type = "application/json") > >> Gazetteer gazetteer) { > >> try { > >> configDb.addGazetteer(gazetteer); > >> } catch (Exception e) { > >> return Response.status(500).build(); > >> } > >> return Response.ok().build(); > >> } > >> > >> The client sends a multipart form posting with JSON in the one and only > >> part, and I expect it to get mapped. What am I missing? > >> > >> > > > > > > -- > View this message in context: > http://www.nabble.com/JAX-RS-form-reading%2C-I%27m-stumped-tp25838462p25846016.html > Sent from the cxf-user mailing list archive at Nabble.com. > >
