Hi On Tue, Apr 26, 2011 at 9:58 AM, Shashank Rachamalla <[email protected]> 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. 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. 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 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 >
