Hi Benson

You can add @Encoded annotation if needed. But note you don't have to use 
@FormParams when handling multipart/form-data, you can
have a MultipartBody in a method signature which will let you access all the 
individual parts.
By the way, thanks for posting the wire representation of the request. As I 
said, at the moment MultipartProvider, the one which can
delegate to other providers to handle individual parts, does not support 
multipart/form-data, as I was thinking that using
multipart/form-data was only appropriate when uploading files, possibly 
together with plain url-encoded (field) values (perhaps it
is indeed what multipart/form-data is mostly for ?).
So for 2.2.5/2.4 is I will update MultipartProvider to extend 
AbstractConfigurableProvider for it to support the dynamic
produces/consumes types configuration and also check how to have a @FormParam handler to delegate to other providers as well (will try to do it this evening), so if needed a user will just explicitly register
MultipartProvider and add "multipart/form-data" to the list of supported 
consumes types which will let you write the code like :

@Consumes("multipart/form-data")
public Response addGazetteer(Gazetter gazetteer) {}

In meantime you can also consider registering a custom MultipartProvider which 
will be a copy of the one on the trunk but with the
updated @Consumes (add "multipart/form-data"). Note  @Multipart annotation is 
an optional one in this case, because a given part has
a Content-Type header, one can use @Multipart similarly to @Consumes but 
applies to an individual part only.


cheers, Sergey

----- Original Message ----- From: "Benson Margulies" <[email protected]>
To: <[email protected]>
Sent: Monday, October 12, 2009 12:43 AM
Subject: Re: JAX-RS form reading, I'm stumped


Sergey,

I have an additional worry here. @FormParam is documented to always
URLDecode. That would be a disaster with multipart/form-data. Is that really
what happens, or is the implementation smart enough to disable decoding for
this case?

--benson


On Sun, Oct 11, 2009 at 2:22 PM, Sergey Beryozkin <[email protected]
wrote:


Sure...

I've been using  this utility : http://www.pocketsoap.com/tcptrace/

So assuming the endpoint is listening on somehost:8080, then you can set up
a tcp trace to redirect from 8081 to 8080 and also modify a form to submit
to 8081

cheers, Sergey

bimargulies wrote:
>
> 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.
>>
>>
>
>

--
View this message in context:
http://www.nabble.com/JAX-RS-form-reading%2C-I%27m-stumped-tp25838462p25846183.html
Sent from the cxf-user mailing list archive at Nabble.com.




Reply via email to