内容类型不支持骆驼DELETE方法?

内容类型不支持骆驼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 属性

请尝试

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不是RESTful方式,应ommited。

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

编辑:

骆驼不主体转移到 DELETE 操作的请求,可以看出挖掘到源$ C ​​$ C。使用 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.