I don't because you clarified the reason - I was merely telling Jose
that I had that line of code he suggested.  Please see my other email
I just sent regarding my attempt to switch to JacksonJaxbJsonProvider.


On Wed, Jul 15, 2015 at 9:38 AM, Sergey Beryozkin <sberyoz...@gmail.com> wrote:
> Hi, why do you expect it working given that you confirmed Book was not a
> JAXB bean and I explained JSONProvider does expect it to be a JAXB bean and
> suggested using Jackson instead ?
>
> Cheers, Sergey
> On 15/07/15 16:33, Chris Wolf wrote:
>>
>> Jose,
>>
>> Thanks for the suggestion, but if you look at the code snippet in my
>> original message, you can see that I already have "providers.add(new
>> JSONProvider());", unless I missed something.
>>
>> Thanks,
>>
>> Chris
>>
>> On Wed, Jul 15, 2015 at 2:56 AM, Jose María Zaragoza
>> <demablo...@gmail.com> wrote:
>>>
>>> 2015-07-14 19:26 GMT+02:00 Chris Wolf <cwolf.a...@gmail.com>:
>>>>
>>>> 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
>
>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com

Reply via email to