Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Stardust/Knowledge Base/Integration/Camel/Calling RESTful Service Through Camel Route

Requirements

We are required to consume external RESTful service from within Stardust processes.

Appropach

To achieve this we will be using Stardust's application integration called Camel Producer Application.

How To Do

Let's assume we will be consuming following 2 RESTful services:

Note: Text in italic are variable values.

We will be modeling a 3 step process for each of the services, in first step we will enter values for the data to be sent to RESTful service, in the second step we will call these RESTful services and in third step we will show the returned results. So all in all we will be defining a 6 step process (4 manual activities and 2 application asctivities, these application activities will be mapped to respective Camel Producer Application interfaces). The process would look something like:


RESTImg6.JPG


The model file can be found here File:RESTConsumer.zip

RESTImg7.JPG

Camel route:

<setHeader headerName="CamelHttpMethod"><constant>GET</constant></setHeader>
<setHeader headerName="CamelHttpUri">
<simple>http://localhost:8080/MyFisrtRESTService/pretech/cardNo?cardNo=$simple{header.cardNo}</simple>
</setHeader>
<to uri="http://isoverwritten" />
<convertBodyTo type="java.lang.String"/>

Camel route:

<setHeader headerName="CamelHttpMethod"><constant>GET</constant></setHeader>
<setHeader headerName="CamelHttpUri">
<simple>http://ajax.googleapis.com/ajax/services/search/web?q=$simple{header.q}&amp;v=$simple{header.v}</simple>
</setHeader>
<to uri="http://isoverwritten" />
<convertBodyTo type="java.lang.String"/>

Back to the top