Hi
On 24/02/12 11:28, Pratyush Chandra wrote:
I am trying to send a multipart form data using web client
Here is the code :
WebClient client =
WebClient.create("http://localhost:8080");
client.accept(MediaType.APPLICATION_JSON);
client.type(MediaType.MULTIPART_FORM_DATA_TYPE);
ContentDisposition cd1 = new ContentDisposition("form-data;
name=\"file\";filename=\"test.txt\"");
ContentDisposition cd2 = new
ContentDisposition("form-data;name=\"textfield\"");
List<Attachment> atts = new LinkedList<Attachment>();
atts.add(new Attachment("textfield", new
ByteArrayInputStream("my_textfield_value".getBytes()), cd2));
atts.add(new Attachment("file", new FileInputStream(new
File("/home/pratyush/test.txt")), cd1));
MultipartBody body = new MultipartBody(atts);
client.post(body, String.class);
With the same code (except for the diff file path) I'm seeing...
26-Feb-2012 17:54:48 org.apache.cxf.interceptor.LoggingInInterceptor
INFO: Inbound Message
----------------------------
ID: 2
Address: http://localhost:9002/bookstore/books/testit
Encoding: ISO-8859-1
Http-Method: POST
Content-Type: multipart/form-data; type="application/octet-stream";
boundary="uuid:8f7f7d09-beb0-4c84-a79f-29a31578dbd3";
start="<textfield>"; start-info="application/octet-stream"
Headers: {Accept=[application/json], Cache-Control=[no-cache],
connection=[keep-alive], content-type=[multipart/form-data;
type="application/octet-stream";
boundary="uuid:8f7f7d09-beb0-4c84-a79f-29a31578dbd3";
start="<textfield>"; start-info="application/octet-stream"],
Host=[localhost:9002], Pragma=[no-cache], transfer-encoding=[chunked],
User-Agent=[Apache CXF ${project.version}]}
Payload:
--uuid:8f7f7d09-beb0-4c84-a79f-29a31578dbd3
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <textfield>
Content-Disposition: form-data;name="textfield"
my_textfield_value
--uuid:8f7f7d09-beb0-4c84-a79f-29a31578dbd3
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <file>
Content-Disposition: form-data;name="file";filename="test.txt"
964 cd ../../
--uuid:8f7f7d09-beb0-4c84-a79f-29a31578dbd3--
Here is the request at server side :
--uuid:87d4e978-49d5-418b-a4d4-7f29b91cd5e5
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID:<textfield>
Content-Disposition: form-data;name="textfield"
my_textfield_value
--uuid:87d4e978-49d5-418b-a4d4-7f29b91cd5e5
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID:<file>
content-disposition: null
test
--uuid:87d4e978-49d5-418b-a4d4-7f29b91cd5e5--
--------------------------------------
I can't figure out why is second context-disposition null ? I am using
cxf-rt-frontend-jaxrs version 2.5.2.
I recall seeing 'content-disposition: null' in one of user's queries
before. As far as I remember, the issue was caused with the the
WebClient posting the form data in scope of the server-side invocation,
and eventually the user reported they fixed something on their side to
make things work properly...
Is there any chance you can provide a simple Maven-based test project ?
Or may be debug (I can help with pointing where to put the breakpoints
if you are interested to investigate)
Thanks, Sergey
--
View this message in context:
http://cxf.547215.n5.nabble.com/Content-Disposition-is-null-in-multipart-form-data-request-tp5512412p5512412.html
Sent from the cxf-user mailing list archive at Nabble.com.
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com