cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shashank Rachamalla <shashank.rachama...@hexagrid.com>
Subject Re: Couldn't find MIME boundary exception while using multipart/form-data
Date Tue, 26 Apr 2011 09:49:37 GMT
Hi

thanks for replying. comments inline.


On Tue, Apr 26, 2011 at 2:52 PM, Sergey Beryozkin <sberyozkin@gmail.com>wrote:

> Hi
>
> On Tue, Apr 26, 2011 at 9:58 AM, Shashank Rachamalla
> <shashank.rachamalla@hexagrid.com> wrote:
> > Hi
> >
> > Can anyone please let me know if I have done something wrong here..
> >
> > *I have exposed the following simple service method ( using cxf 2.3.3 ) *
> >
> >    @Override
> >    @POST
> >    @Consumes(MediaType.MULTIPART_FORM_DATA)
> >    public Response saveForm() {
> >        System.out.println(AttachmentUtils.getAttachments(mc).size());
> >        return Response.status(Response.Status.OK).build();
> >    }
>
> I think the problem might be related to the fact you are calling
>
> AttachmentUtils.getAttachments(mc) directly, I'm assuming 'mc' is
> referring to injected MessageContext.
>
> yes, mc is referring to injected MessageContext


> I can actually see few tests where AttachmentUtils is called directly
> in the tests, ex, for simple form-data submissions:
>
> MultivaluedMap<String, String> data =
> AttachmentUtils.populateFormMap(context);
> and
> AttachmentUtils.getMultipartBody(context)
>
> but may be you have to explicitly add MultipartBody as a method
> parameter - this will ensure MultipartProvider is invoked and it does
> some multipart/form-data related processing, so it may help.
>

fine. i will try this out now.


> More comments inline
>
> >
> > *The following is a request ( captured through tcpmon ) to the above
> defined
> > service method:* ( it is a form post )
> >
> > POST /api/v1/rest HTTP/1.1
> > Host: localhost:8081
> > User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3)
> > Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3
> > Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> > Accept-Language: en-us,en;q=0.5
> > Accept-Encoding: gzip,deflate
> > Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> > Keep-Alive: 115
> > Connection: keep-alive
> > Referer: http://localhost/form.html
> > Content-Type: multipart/form-data;
> > boundary=---------------------------91021093918280655661679102041
>

tcpmon shows boundary on the same line.


> Can it be a problem ? I'm not sure if the boundary parameter is shown
> on the next line by tcpmon or actually located on the next line, which
> is probably correct, but may be it's confusing CXF a bit ?
>
> > Content-Length: 345
> >
> > -----------------------------91021093918280655661679102041
> > Content-Disposition: form-data; name="title"
> >
> > test
> > -----------------------------91021093918280655661679102041
> > Content-Disposition: form-data; name="file"; filename="test.txt"
> > Content-Type: text/plain
> >
> > file content
> >
> > -----------------------------91021093918280655661679102041--
> >
>
> Can it be that the extra line between 'file content' and the final
> boundary is present ?
>
> >
> > *The following is the response received for above request:*
> >
> > <ns1:XMLFault>
> > <ns1:faultstring>
> > java.io.IOException: Couldn't find MIME boundary:
> > -----------------------------91021093918280655661679102041
> > </ns1:faultstring>
> > </ns1:XMLFault>
> >
> > Thanks in advance !
> >
>
> Please try adding MultipartBody to the method signature and I'll do a
> test a bit later on too,
>
> thanks, Sergey
>
>
> >
> > Regards,
> > Shashank Rachamalla
> >
>



-- 
Regards,
Shashank Rachamalla

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message