Apache Came组件rest的使用
来源:互联网 发布:证大财富淘宝贷假不假 编辑:程序博客网 时间:2024/04/30 10:56
The rest component allows to define REST endpoints using the Rest DSL and plugin to other Camel components as the REST transport.
代码如下:
<camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring"><restConfiguration bindingMode="auto" component="restlet" port="3387" /><!-- 用法一 --><rest path="/api"><!-- 访问路径 http://127.0.0.1:3387/api/products --><get uri="/products"><to uri="direct:products" /></get><!-- 访问路径 http://127.0.0.1:3387/api/product/{id} --><get uri="/product/{id}"><to uri="direct:product" /></get><!-- 访问路径 http://127.0.0.1:3387/api/product/create(post请求方式) --><post uri="/product/create"><to uri="bean:productNew" /></post></rest><route><from uri="direct:products" /><setBody><constant>this is products list</constant></setBody></route><route><from uri="direct:product" /><to uri="log:show1?showAll=true&multiline=true" /><setBody><simple>this is product ${in.header.id}</simple></setBody></route><!-- 用法二 --><route><!-- 访问地址为 http://127.0.0.1:3387/topics --><from uri="rest:get:topics" /><setBody><constant>this is topic list</constant></setBody></route><!-- 访问地址为 http://127.0.0.1:3387/topic/111 --><route><from uri="rest:get:topic/{id}" /><setBody><simple>this is topic[id=${in.header.id}]</simple></setBody></route></camelContext>
最后,加入maven依赖
<dependency><groupId>org.apache.camel</groupId><artifactId>camel-restlet</artifactId><version>2.15.3</version></dependency>
7 0
- Apache Came组件rest的使用
- Apache Came组件http4的使用
- Apache commons组件的使用
- 使用Apache CXF搭建REST风格的Web Service
- Excel的解析--使用apache POI组件
- Apache common-fileupload 组件的使用实例
- Apache BeanUtils组件使用
- rest的使用
- Apache Camel配置SSL的rest
- Livy:基于Apache Spark的REST服务
- Livy:基于Apache Spark的REST服务
- Livy:基于Apache Spark的REST服务
- Apache的FileUpload组件
- Apache的FileUpload组件
- apache的Email组件
- Apache组件commons的Codec包的使用实例
- Java使用Apache的FileUpload组件进行文件上传
- Struts2 Rest Plugin的使用
- sizeof
- 【转】iPhone易被窃听应用三分钟即可获取所有信息--之文章
- JDK源码 -- Map篇
- [PHP]PHP函数
- hdu4616 树形dp(有限制的权值最大链)
- Apache Came组件rest的使用
- C++ <替换字符串中的数字>
- 越长大越孤单
- spring cron表达式
- 自有域名、IIS7,搭建SMTP邮件服务器
- 【黑马程序员】第三篇_关于I/O的总结
- printf 使用
- Android Studio为APP签名,提取签名的SHA1/MD5编码
- 从一个盒子模型说起