Вопрос

I have a restful service with uri

 http://<host>:<port>/resource/Item/100

where 100 is a parameter. How do i set up a from camel route in xml for this

<camel:route id="A">
  <camel:from uri="http://<host>:<port>/resource/Item/{param}">
Это было полезно?

Решение

If you use camel-restlet as the restlet service, then read its documentation at: http://camel.apache.org/restlet - it has examples how to define a parameter.

Though your example above already define the 100 as {param}, you can give it any name you like, such as itenNumber, itemNo etc

<camel:from uri="restlet:http://<host>:<port>/resource/Item/{itemNo}">

Then in Camel {itemNo} gets mapped to a header on the message, eg: itemNo = key, and the content its value, eg for example 100 in your example.

And in the upcoming Apache Camel 2.12 release we have a camel-restlet-jdbc example out of the box. You can find its source here where you can see an example: https://git-wip-us.apache.org/repos/asf?p=camel.git;a=tree;f=examples/camel-example-restlet-jdbc;h=e4796a8cbe84dedae4bc0ec98e8997128c9be7a6;hb=HEAD

Besides camel-restlet then camel-cxfrs can also be used for restful services.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top