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.
Difference between revisions of "Stardust/Knowledge Base/Integration/Camel/Calling RESTful Service Through Camel Route"
Line 17: | Line 17: | ||
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: | 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: | ||
− | + | ||
− | [[File:RESTImg6. | + | [[File:RESTImg6.JPG]] |
− | The model file can be found here [[File:RESTConsumer.zip]] | + | |
+ | <br>The model file can be found here [[File:RESTConsumer.zip]] | ||
:* Configuring Camel Producer Application to Consume http://localhost:8080/MyFisrtRESTService/pretech/cardNo?cardNo=''1002'' | :* Configuring Camel Producer Application to Consume http://localhost:8080/MyFisrtRESTService/pretech/cardNo?cardNo=''1002'' | ||
− | [[File:RESTImg7. | + | [[File:RESTImg7.JPG]] |
Camel route: | Camel route: |
Revision as of 07:12, 9 January 2014
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:
The model file can be found here File:RESTConsumer.zip
- Configuring Camel Producer Application to Consume http://localhost:8080/MyFisrtRESTService/pretech/cardNo?cardNo=1002
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"/>
- Configuring Camel Producer Application to Consume http://ajax.googleapis.com/ajax/services/search/web?q=Himalya&v=1.0
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}&v=$simple{header.v}</simple> </setHeader> <to uri="http://isoverwritten" /> <convertBodyTo type="java.lang.String"/>