150.13. 如何将 http 方法(GET/PATCH/POST/PUT/DELETE/HEAD/OPTIONS/TRACE)设置为 HTTP producer
使用 http PATCH 方法
从 Camel 2.11.3 / 2.12.1 开始,支持 http PATCH 方法。
HTTP4 组件通过设置消息标头来提供设置 HTTP 请求方法的方法。下面是一个示例:
from("direct:start")
.setHeader(Exchange.HTTP_METHOD, constant(org.apache.camel.component.http4.HttpMethods.POST))
.to("http4://www.google.com")
.to("mock:results");可以使用字符串常量编写一些方法:
.setHeader("CamelHttpMethod", constant("POST"))以及对等的 Spring 示例:
<camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="direct:start"/>
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<to uri="http4://www.google.com"/>
<to uri="mock:results"/>
</route>
</camelContext>