You can try something like this. Include json specific jars as applicable
for the ObjectMapper.
from("direct:getRestFromExternalService")
.to("http4://www.externalRestServiceUri"")
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
String jsonString = exchange.getIn().getBody(String.class);
ObjectMapper mapper = new ObjectMapper(); // import
com.fasterxml.jackson.databind.ObjectMapper;
RestObject post = mapper.readValue(jsonString,
RestObject .class);
}
})
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate5</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hppc</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-json-org</artifactId>
<version>${jackson.version}</version>
</dependency>
On Mon, Feb 27, 2017 at 5:29 PM, rkmohapatra <[email protected]> wrote:
> Hi,
>
> I am a newbie to Apache Camel.
> I am using Apache Camel 2.18.2 and trying to build an application that
> needs
> to do this
>
> - Make a REST call to fetch data in JSON format. The REST service is
> external to the application where Camel is deployed.
> - Process the JSON data and store in a target database.
>
> As per my understanding from earlier posts, I can use
> camel-http/camel-cxf/camel-jetty for this purpose. Which one I should
> prefer
> from these based on the above requirement?
>
> Also, please point me to an example that I can refer to understand more
> about this.
>
> Thanks,
> Rajesh
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.
> com/Consuming-data-from-external-REST-service-tp5794514.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
- Ravi
*[ View My Youtube Channel ] <https://www.youtube.com/c/RavindraGodbole>*
Phone: +91 *98 509 760 91*