camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From souciance <souciance.eqdam.ras...@gmail.com>
Subject Re: ProducerTemplate not able to unmarshal response to Java object.
Date Tue, 24 May 2016 11:00:35 GMT
Do you actually get a response here?
Contact contact = producerTemplate.requestBodyAndHeaders(
                                "http://localhost:8080/api/contact/2345",
                                null, headers, Contact.class);

Check if contact is not null before you try to unmarshal.

On Tue, May 24, 2016 at 11:17 AM, ndsurendra [via Camel] <
ml-node+s465427n5783011h4@n5.nabble.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.
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://camel.465427.n5.nabble.com/ProducerTemplate-not-able-to-unmarshal-response-to-Java-object-tp5783011.html
> To start a new topic under Camel - Users, email
> ml-node+s465427n465428h31@n5.nabble.com
> To unsubscribe from Camel - Users, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://camel.465427.n5.nabble.com/ProducerTemplate-not-able-to-unmarshal-response-to-Java-object-tp5783011p5783026.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message