I am trying to implement a rest web service using Apache CXF and I want to return list of object as a response from server. So i have used generic entity to wrap my list on a server and everything is fine when I enter path from browser. It prints XML representation of object because I have used Jackson JAX-B but when i try to use JAX-RS client. I am getting an exception.
Exception in thread "main" javax.ws.rs.client.ResponseProcessingException: Problem with reading the data, class XYZ, ContentType: /. at org.apache.cxf.jaxrs.impl.ResponseImpl.reportMessageHandlerProblem(ResponseImpl.java:433) at org.apache.cxf.jaxrs.impl.ResponseImpl.doReadEntity(ResponseImpl.java:378) at org.apache.cxf.jaxrs.impl.ResponseImpl.readEntity(ResponseImpl.java:325) at org.apache.cxf.jaxrs.impl.ResponseImpl.readEntity(ResponseImpl.java:313) at XYZ.ABC() at XYZ.ABC() Caused by: javax.ws.rs.core.NoContentException: Message body is empty at org.apache.cxf.jaxrs.provider.AbstractJAXBProvider.reportEmptyContentLength(AbstractJAXBProvider.java:276) at org.apache.cxf.jaxrs.provider.JAXBElementProvider.readFrom(JAXBElementProvider.java:166) at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBodyReader(JAXRSUtils.java:1325) at org.apache.cxf.jaxrs.impl.ResponseImpl.doReadEntity(ResponseImpl.java:369) ... 4 more
I have written a following client code to get data from server final Client client = ClientBuilder.newClient(); WebTarget webTarget = client.target(URI.create(PATH)); Response response = webTarget.request(MediaType.APPLICATION_XML).get(); List<ABC> obj = response.readEntity(new GenericType<List<ABC>> (ABC.class){});
But Apart from it I have tried many code to implement CXF client and get data from server but I am getting a same exception almost all the time. I have tried JAXRSCLIENTFactory also to implement client but the same exception.
Aucun commentaire:
Enregistrer un commentaire