3.12. 如何将 http 方法设置为 HTTP producer
HTTP 组件通过设置 message 标头来提供设置 HTTP 请求方法的方法。以下是一个示例:
from("direct:start")
.setHeader(Exchange.HTTP_METHOD, constant("POST"))
.to("ahc:http://www.google.com")
.to("mock:results");以及对等的 Spring 示例:
<camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="direct:start"/>
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<to uri="ahc:http://www.google.com"/>
<to uri="mock:results"/>
</route>
</camelContext>