Camel DELETE 方法不支持 Content-Type? [英] Content-Type is not supported in Camel DELETE method?

查看:51
本文介绍了Camel DELETE 方法不支持 Content-Type?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在 Camel DELETE 方法中发送内容类型.我添加了以下方式,但它无法正常工作.

How do i send content-type in Camel DELETE method. I have added the following way but It was not working correctly.

from("direct:start")
.setHeader(Exchange.HTTP_METHOD, simple("DELETE"))
.setHeader(Exchange.CONTENT_TYPE, simple("application/xml")) 
.setHeader(Exchange.HTTP_URI, simple("http://02.02.02.02:8080/rest/delete/student/688187"))
.to("http://emptyhost");

你能帮我解决这个问题吗?

推荐答案

在删除操作中,不发送任何内容,因此不需要 Exchange.CONTENT_TYPE 属性.

As in a delete operation, no content is sent, the Exchange.CONTENT_TYPE property should not be needed.

请试试

from("direct:start")
    .setHeader(Exchange.HTTP_METHOD, simple("DELETE"))
    .to("http://02.02.02.02:8080/rest/delete/student/688187");

from("direct:start")
    .to("restlet:http://02.02.02.02:8080/rest/delete/student/688187?restletMethod=delete");

顺便说一下,在 URL 中使用 delete 不是 RESTful 方式,应该省略.

By the way, using delete in the URL is not the RESTful way and should be ommited.

Camel 不会将 body 传输到 DELETE 操作的请求,正如挖掘源代码所见.请改用 PUT 操作.请参阅我对您的其他回答 SO.

Camel does not transfer the body to the request of a DELETE operation, as can be seen digging into the source code. Use a PUT operation instead. See my answer to your other SO.

这篇关于Camel DELETE 方法不支持 Content-Type?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆