3.11. HTTP プロデューサーに http メソッドを設定する方法
HTTP コンポーネントは、メッセージヘッダーを設定することにより、HTTP 要求メソッドを設定する方法を提供します。以下に例を示します。
from("direct:start") .setHeader(Exchange.HTTP_METHOD, constant("POST")) .to("ahc:http://www.google.com") .to("mock:results");
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>
<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>