Producer template can produce to camel end points. Setup a camel route with http
component and configure the given url in it. Now produce to that endpoint and
convert the response to the required object type. Hope this helps





On Tue, May 24, 2016 2:47 PM, ndsurendra ndsuren...@gmail.com wrote:
I used the ProducerTemplate to send a http request and get the response like

this.




Contact contact = producerTemplate.requestBodyAndHeaders(

"http://localhost:8080/api/contact/2345";,

null, headers, Contact.class);




logger.info("Contact is: " + new

ObjectMapper().writeValueAsString(contact));




I get the contact as null.







When I try to get it as Object like this:




Object contact = producerTemplate.requestBodyAndHeaders(

"http://localhost:8080/api/contact/2345";,

null, headers);







logger.info("Contact is: " + new

ObjectMapper().writeValueAsString(contact));




com.fasterxml.jackson.databind.JsonMappingException: No serializer found for

class

org.apache.camel.converter.stream.CachedOutputStream$WrappedInputStream and

no properties discovered to create BeanSerializer (to avoid exception,

disable SerializationFeature.FAIL_ON_EMPTY_BEANS) )







Why is ProducerTemplate not able to unmarshall the response to the specified

object?

How can this be achieved?




Thanks,

Surendra.










--

View this message in context:
http://camel.465427.n5.nabble.com/ProducerTemplate-not-able-to-unmarshal-response-to-Java-object-tp5783011.html

Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to