Hi
Here is the test involving WebClient :
@Test
public void testAddGetJaxbBooksWebClient() throws Exception {
String address = "http://localhost:" + PORT +
"/bookstore/books/jaxbonly";
WebClient client = WebClient.create(address);
client.type("multipart/mixed;type=application/xml").accept("multipart/mixed");
Book b = new Book("jaxb", 1L);
Book b2 = new Book("jaxb2", 2L);
List<Book> books = new ArrayList<Book>();
books.add(b);
books.add(b2);
Collection<? extends Book> coll = client.postAndGetCollection(books,
Book.class);
List<Book> result = new ArrayList<Book>(coll);
Book jaxb = result.get(0);
assertEquals("jaxb", jaxb.getName());
assertEquals(1L, jaxb.getId());
Book jaxb2 = result.get(1);
assertEquals("jaxb2", jaxb2.getName());
assertEquals(2L, jaxb2.getId());
}
where the server code is :
@POST
@Path("/books/jaxbonly")
@Consumes("multipart/mixed")
@Produces("multipart/mixed;type=text/xml")
public List<Book> addBooks(List<Book> books) {
List<Book> books2 = new ArrayList<Book>();
books2.addAll(books);
return books2;
}
I've just added a proxy test :
@Test
public void testAddCollectionOfBooksWithProxy() {
String address = "http://localhost:" + 8080;
MultipartStore client = JAXRSClientFactory.create(address,
MultipartStore.class);
WebClient.client(client).header("Content-Type",
"multipart/mixed;type=application/xml");
List<Book> books = new ArrayList<Book>();
books.add(new Book("CXF 1", 1L));
books.add(new Book("CXF 2", 2L));
List<Book> books2 = client.addBooks(books);
assertNotSame(books, books2);
assertEquals(2, books2.size());
assertEquals(books.get(0).getId(), books2.get(0).getId());
assertEquals(books.get(1).getId(), books2.get(1).getId());
}
Note that a proxy "helps" the MultipartProvider to figure out the type of
individual collection parts.
@Consumes("multipart/mixed;type=application/xml") should work too - it works
in my local snapshot - but I'll need to run more tests first before
committing a minor fix to MediaType handler to do with handling complex
types usually contained in multipart requests.
thanks, Sergey
On Tue, Oct 5, 2010 at 7:40 PM, oceanz <[email protected]> wrote:
>
> Josh,
>
> I tried to wrap it up.But still the same problem.Any furthur pointers?
>
> Thanks.
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/Help-required-with-apache-cxf-multiparts-tp3199975p3200207.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>