Ah damn it... It was the wrapper thing again. I missed using naming convention when I wrapped.
Thanks again!
Skickat från min iPhone
> 3 nov. 2016 kl. 17:41 skrev Romain Manni-Bucau <rmannibucau@gmail.com>:
>
> Hi
>
> you didnt register jettison so the wrapper is not handled by default json
> mapper which would expects {"test":"test"}
>
> Another solution is to rewrite HelloWorldDTO to add a wrapper with a field
> hellowWorldDto of type HelloWorldDTO
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> | Blog
> <https://blog-rmannibucau.rhcloud.com> | Old Blog
> <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau>
|
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
> <https://javaeefactory-rmannibucau.rhcloud.com>
>
> 2016-11-03 17:32 GMT+01:00 Karl Kildén <karl.kilden@gmail.com>:
>
>> Hi!
>>
>> I am trying to consume a restful service with TomEE 7 and jax-rs Client. I
>> copied the DTO between the projects. The other system uses a fairly old
>> jersey impl and I can't change that for now.
>>
>> I have this DTO
>>
>> import javax.xml.bind.annotation.XmlRootElement;
>>
>>
>> @XmlRootElement
>> public class HelloWorldDTO {
>>
>> private String test = "test";
>>
>> public String getTest() {
>> return test;
>> }
>>
>> public void setTest(String test) {
>> this.test = test;
>> }
>> }
>>
>> The service I am calling gives this response in the browser when I try the
>> service that way:
>>
>> {"helloWorldDTO":{"test":"test"}}
>>
>> The way I doing the call is:
>> client.target(builder).request(MediaType.APPLICATION_
>> JSON).get(HelloWorldDTO.class)
>>
>> The URL is correct and response code is correct etc... I get the
>> entity but the property test is null but it was sent as "test".
>>
>>
>> Any tips on how to debug this? Should I try adding a wrapper on any
>> side? :) I think I did try that but it did not help. In my real use
>> case I need to send several and I have a wrapper with a List. When it
>> came across as null I tried just with a simple property and still the
>> problem persists.
>>
>> Thankful for advice!
>>
>>
>> Cheers
>>
|