Hi
I am trying to write a service which will be responsible for uploading a
file by taking the file as an array of bytes in the POST Entity. Here is my
code
*My CXF Service*
@Path("MyTest")
public class TestService {
@POST
public String MyPost(Byte[] bytes){
System.out.println("Service invoked");
return "Hello, I am a POST response";
}
}
*My Client*
File image = new File("C:\\snake.jpg");
FileInputStream is = new FileInputStream(image);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] fileInBytes = bos.toByteArray();
Client client = ClientBuilder.newClient();
WebTarget target = client.target("http://localhost:8080/MyApp");
target = target.path("MyTest");
Response response = target.request().post(Entity.entity(fileInBytes,
MediaType.APPLICATION_OCTET_STREAM));
InputStream i = (InputStream) response.getEntity();
BufferedReader br = new BufferedReader(new InputStreamReader(i));
System.out.println(br.readLine());
*And this is the error that I get*
SEVERE: No message body reader has been found for class [Ljava.lang.Byte;,
ContentType: application/octet-stream
Nov 06, 2014 4:02:50 PM
org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
WARNING: javax.ws.rs.WebApplicationException: HTTP 415 Unsupported Media
Type
at
org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBody(JAXRSUtils.java:1298)
...
Any ideas about it?
Thanks
--
View this message in context:
http://cxf.547215.n5.nabble.com/CXF-No-Message-body-reader-found-for-byte-array-parameter-in-POST-service-tp5750793.html
Sent from the cxf-user mailing list archive at Nabble.com.