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 操作?
基础教程推荐
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
