Hi
I've updated the local test with this code:
@Test
public void test() {
Client client = ClientBuilder.newBuilder()
.register(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider.class)
.build();
WebTarget target = client.target("http://localhost:" + PORT +
"/bookstore/bookheaders/simple");
Invocation.Builder builder = target.request().accept("application/json");
byte [] theBytes = new byte[]{11, 11};
Entity<byte[]> entity = Entity.entity(theBytes,
MediaType.APPLICATION_OCTET_STREAM);
builder.post(entity);
}
and it os definitely hitting the remote endpoint - the error is returned
but it is expected as the server side preconditions are not met (in the
case of CXF systest/jaxrs JAXRS20ClientServerBookTest)
Can you please try CXF 3.0.4 ? Though I'd expect the same code work with
3.0.0.
Thanks, Sergey
On 25/02/15 15:59, lcasapu wrote:
I have registered Jackson as a provider for CXF 3.0, and I can use it to
serialize XML from JAXB beans just fine. When I try to upload a file to
another external server that consumes multipart, I get the following error:
No message body writer has been found for class [B, ContentType:
application/octet-stream
The relevant code section is here:
Client client = ClientBuilder.newBuilder()
.register(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider.class)
.build();
WebTarget target = client.target(targetUrl);
builder = target.request();
builder = builder.accept(headersMap.get(HttpHeaders.ACCEPT));
byte [] theBytes = getBytes(theFile);
Entity<byte[]> entity = Entity.entity(theBytes,
MediaType.APPLICATION_OCTET_STREAM);
response = builder.post(entity);
I get the same message (different class, as expected) when I try InputStream
or File instead of byte[]. To my understanding, all these types shall be
handled automatically - there is no need for to register a custom
Provider/MessageBodyWriter. Am I wrong ?
PS All CXF examples on uploading multipart show the 2.7 style of using
WebClient. Is there any CXF documentation on JAX-RS 2.0 style ?
Thanks a lot,
Liviu
--
View this message in context:
http://cxf.547215.n5.nabble.com/Unable-to-upload-file-content-using-CXF-3-0-0-and-Jackson-2-2-0-tp5754611.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