How to call Rest API DELETE operation with BODY content from Apache Camel?(如何使用 Apache Camel 的 BODY 内容调用 Rest API DELETE 操作?)
问题描述
我需要使用正文内容调用 rest DELETE 操作.我有其他方法可以做到这一点,但这是我们的要求.我尝试了以下方式,但无法获得输出.你能给我一个想法来实现这个吗?
I need to call rest DELETE operation with body content. I have alternative way to do this but this is our requirement. I have tried the following way but unable to get an output. Can you give me an IDEA to achieve this?
这是我的代码:
from("direct:start")
.setHeader(Exchange.HTTP_METHOD, simple("DELETE"))
.setHeader(Exchange.CONTENT_LENGTH, simple("64"))
.setBody(simple("<stundent>...</student>")))
.to("http://10.1.1.1:8080/rest/student/delete/1029");
推荐答案
正如我在你的其他 SO,不要使用 DELETE
而是 PUT
操作.
As I stated in your other SO, do not use a DELETE
but a PUT
operation.
深入HttpProducer
,如果methodToUse.isEntityEnclosed()
是 true
(第 367 行).但是,这仅适用于 PUT
和 POST
,因为只有这些方法实现扩展了类 EntityEnclosingMethod
.不幸的是,DELETE
并非如此.
Digging into the source code of HttpProducer
, you can see that the request is filled if methodToUse.isEntityEnclosed()
is true
(line 367). However, this is only the case for PUT
and POST
as only those method implementations extend the class EntityEnclosingMethod
. Unfortunately for you, this is not the case for DELETE
.
这篇关于如何使用 Apache Camel 的 BODY 内容调用 Rest API DELETE 操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 Apache Camel 的 BODY 内容调用 Rest API DELETE 操作?


- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01