2015-07-14 19:26 GMT+02:00 Chris Wolf <[email protected]>: > Again, referring to the example code at: > > https://cwiki.apache.org/confluence/display/CXF20DOC/JAXRS+Testing > > This client code works: > > @Test > public void testGetBookWithProxy() { > MyJaxrsResource client = > JAXRSClientFactory.create(ENDPOINT_ADDRESS, MyJaxrsResource.class); > > WebClient.getConfig(client).getRequestContext().put(LocalConduit.DIRECT_DISPATCH, > Boolean.TRUE); > WebClient.getConfig(client).setBus(bus); > Response r = client.getBook("123"); > String bookJSON = r.readEntity(String.class); > log.info("JAXRS Client result: {}", bookJSON); > } > > ...but this client code (which should try to unmarshall to object) doesn't > work: > > @Test > public void testGetBookWithWebClient() { > List<Object> providers = new ArrayList<Object>(); > // add custom providers if any > providers.add(JSONProvider.class); > > WebClient client = WebClient.create(ENDPOINT_ADDRESS, providers); > client.accept("application/json"); > client.path("shelf/book"); > Book book = client.query("id", 123L).get(Book.class); > assertEquals(123L, book.getId()); > } > > > The error is: > > ResponseProcessingException: No message body reader has been found for > class CXF_Test.cxf_test.Book, ContentType: application/json > > However, as can be seen, I configured the "JSONProvider", which I > thought would unmarshal JSON to POJOs. > > Any ideas?
Why don't you try providers.add(new JSONProvider()); ? This worked for me. Regards
