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 操作?


基础教程推荐
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 大摇大摆的枚举 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 从 python 访问 JVM 2022-01-01