Hi Dave

On Thu, Jul 21, 2011 at 6:01 PM, Collard, David L (Dave)
<dave.coll...@alcatel-lucent.com> wrote:
>
> Hi Sergey,
>
> No, I am not using struts.
>
> I made a simpler standalone example.
>
> //------------------------------------------------------------------------------------------------
> package tests.cxf.multi;
>
> import java.util.List;
>
> import javax.ws.rs.Consumes;
> import javax.ws.rs.POST;
> import javax.ws.rs.Path;
>
> import org.apache.cxf.jaxrs.ext.multipart.Multipart;
> import org.apache.log4j.Logger;
>
> @Path("/tests/cxf/books")
> public class MultipartBooks {
>      private static Logger log = Logger.getLogger(MultipartBooks.class);
>
>      public MultipartBooks() {}
>
>      @POST
>      @Path("jsonform")
>      @Consumes("multipart/form-data")
>      public void addBookJsonFromForm(Book b1) {
>            log.debug("MULTIPARTBOOKS: addBookJsonFromForm, Book:" + 
> b1.getName() + ", id:" + b1.getId());
>      }
>
>      @POST
>      @Path("filesform")
>      @Consumes("multipart/form-data")
>      public void addBookFilesForm(
>                  @Multipart("owner") String name,
>                  @Multipart("files")     List<Book> books) {
>            log.debug("MULTIPARTBOOKS: addBookFilesForm, owner name:" + name + 
> ", count:" + books.size());
>            for (Book book : books) {
>                  log.debug("  Book " + book.getName());
>            }
>      }
>
> }
> //---------------------------------------------------------------------------------------
>
> I am using firefox REST Client to send the request.
>
> The saved request with NO content-id:
>
> {"requestUrl":"http://<IP 
> ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform","requestMethod":"POST","requestBody":"--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition:
>  form-data; name=\"owner\"\u000aContent-Type: 
> text/plain\u000a\u000aLarry\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition:
>  form-data; name=\"files\"\u000aContent-Type: multipart/mixed; 
> boundary=_Part_4_701508.1145579811786\u000a\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition:
>  form-data; name=\"book1\"\u000aContent-Type: application/json; 
> charset=US-ASCII\u000aContent-Transfer-Encoding: 
> 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 
> 1\",\"id\":123}}\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition:
>  form-data; name=\"book2\"\u000aContent-Type: application/json; 
> charset=US-ASCII\u000aContent-Transfer-Encoding: 
> 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 
> 2\",\"id\":124}}\u000a--_Part_4_701508.1145579811786--\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB--","headers":["Content-Type","multipart/form-data;
>  boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB"]}
>
> Resulting log:
>
> Jul 21, 2011 12:31:07 PM 
> org.apache.cxf.interceptor.AbstractLoggingInterceptor log
> INFO: Inbound Message
> ----------------------------
> ID: 11
> Address: http://<IP 
> ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform
> Encoding: UTF-8
> Http-Method: POST
> Content-Type: multipart/form-data; charset=UTF-8; 
> boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Headers: 
> {Accept=[audio/x-wav,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5],
>  accept-charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.7], accept-encoding=[gzip, 
> deflate], cache-control=[no-cache], connection=[keep-alive], 
> Content-Length=[735], content-type=[multipart/form-data; charset=UTF-8; 
> boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB], 
> cookie=[JSESSIONID=58E6D8C6B7C8CC2812E3F19CE3CEE892], host=[<IP 
> ADDRESS>:8080], pragma=[no-cache], user-agent=[Mozilla/5.0 (Windows NT 5.1; 
> rv:5.0.1) Gecko/20100101 Firefox/5.0.1]}
> Payload: --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Content-Disposition: form-data; name="owner"
> Content-Type: text/plain
>
> Larry
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Content-Disposition: form-data; name="files"
> Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
>
> --_Part_4_701508.1145579811786
> Content-Disposition: form-data; name="book1"
> Content-Type: application/json; charset=US-ASCII
> Content-Transfer-Encoding: 8bit
>
> {"Book":{"name":"CXF in Action - 1","id":123}}
> --_Part_4_701508.1145579811786
> Content-Disposition: form-data; name="book2"
> Content-Type: application/json; charset=US-ASCII
> Content-Transfer-Encoding: 8bit
>
> {"Book":{"name":"CXF in Action - 2","id":124}}
> --_Part_4_701508.1145579811786--
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB--
> --------------------------------------
> Jul 21, 2011 12:31:07 PM org.apache.cxf.jaxrs.utils.multipart.AttachmentUtils 
> getMultipart
> WARNING: No multipart with content id files found, request content type : 
> multipart/form-data;boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB;charset=UTF-8
> Jul 21, 2011 12:31:07 PM 
> org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
> WARNING: WebApplicationException has been caught : no cause is available
> Jul 21, 2011 12:31:07 PM 
> org.apache.cxf.interceptor.AbstractLoggingInterceptor log
> INFO: Outbound Message
> ---------------------------
> ID: 11
> Response-Code: 404
> Content-Type: text/xml
> Headers: {Date=[Thu, 21 Jul 2011 16:31:07 GMT]}
>
>
> The saved request with content-id:
>
> {"requestUrl":"http:// <IP 
> ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform","requestMethod":"POST","requestBody":"--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition:
>  form-data; name=\"owner\"\u000aContent-Type: 
> text/plain\u000a\u000aLarry\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition:
>  form-data; name=\"files\"\u000aContent-Type: multipart/mixed; 
> boundary=_Part_4_701508.1145579811786\u000aContent-Id: 
> <files>\u000a\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: 
> form-data; name=\"book1\"\u000aContent-Type: application/json; 
> charset=US-ASCII\u000aContent-Transfer-Encoding: 
> 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 
> 1\",\"id\":123}}\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition:
>  form-data; name=\"book2\"\u000aContent-Type: application/json; 
> charset=US-ASCII\u000aContent-Transfer-Encoding: 
> 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 
> 2\",\"id\":124}}\u000a--_Part_4_701508.1145579811786--\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB--","headers":["Content-Type","multipart/form-data;
>  boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB"]}
>
> Resulting log:
>
> Jul 21, 2011 12:32:05 PM 
> org.apache.cxf.interceptor.AbstractLoggingInterceptor log
> INFO: Inbound Message
> ----------------------------
> ID: 12
> Address: http:// <IP 
> ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform
> Encoding: UTF-8
> Http-Method: POST
> Content-Type: multipart/form-data; charset=UTF-8; 
> boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Headers: 
> {Accept=[audio/x-wav,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5],
>  accept-charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.7], accept-encoding=[gzip, 
> deflate], cache-control=[no-cache], connection=[keep-alive], 
> Content-Length=[755], content-type=[multipart/form-data; charset=UTF-8; 
> boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB], 
> cookie=[JSESSIONID=58E6D8C6B7C8CC2812E3F19CE3CEE892], host=[<IP 
> ADDRESS>:8080], pragma=[no-cache], user-agent=[Mozilla/5.0 (Windows NT 5.1; 
> rv:5.0.1) Gecko/20100101 Firefox/5.0.1]}
> Payload: --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Content-Disposition: form-data; name="owner"
> Content-Type: text/plain
>
> Larry
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Content-Disposition: form-data; name="files"
> Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
> Content-Id: <files>
>
> --_Part_4_701508.1145579811786
> Content-Disposition: form-data; name="book1"
 Content-Type: application/json; charset=US-ASCII
> Content-Transfer-Encoding: 8bit
>
> {"Book":{"name":"CXF in Action - 1","id":123}}
> --_Part_4_701508.1145579811786
> Content-Disposition: form-data; name="book2"
> Content-Type: application/json; charset=US-ASCII
> Content-Transfer-Encoding: 8bit
>
> {"Book":{"name":"CXF in Action - 2","id":124}}
> --_Part_4_701508.1145579811786--
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB--
> --------------------------------------
> DEBUG MultipartBooks                 [31] - MULTIPARTBOOKS: addBookFilesForm, 
> owner name:Larry
> , count:2
> DEBUG MultipartBooks                 [33] -   Book CXF in Action - 1
> DEBUG MultipartBooks                 [33] -   Book CXF in Action - 2
> Jul 21, 2011 12:32:05 PM 
> org.apache.cxf.interceptor.AbstractLoggingInterceptor log
> INFO: Outbound Message
> ---------------------------
> ID: 12
> Response-Code: 204
> Content-Type: text/xml
> Headers: {Date=[Thu, 21 Jul 2011 16:32:05 GMT]}
>
> I am using tomcat 7.0.14, CXF 2.4.1, linux red hat Enterprise Server5.5.
>
> If you like, I can send you a war file, or eclipse project.   File sharing 
> sites
> are blocked from here or I would put it to dropbox or similar.
>
thanks for the above analysis, I'm not sure why I'm not seeing the
same issue - I guess I could try
Tomcat 7.0.14 as well and/or RESTClient (just installed). Can I paste
the request fragment above as is in RESTClient ?
If you could send me a war with only MultipartBooks.class (I'll add
cxf distro libs myself) then it will help me to test quickly

Cheers, Sergey

> Thanks!
>
> -- Dave Collard
>

Reply via email to