如何在apache camel

时间:2017-02-26 00:06:29

标签: apache apache-camel

这里我从客户端收到请求,只是重定向请求并将响应发送给客户端。我想在响应中添加标题。您能否指导我,如何为下面提到的代码添加标题以响应。

<camel:camelContext xmlns="http://camel.apache.org/schema/spring">
<camel:route trace="true" id="ProxyRepo2">
    <camel:from uri="jetty:http://localhost:8299/test?matchOnUriPrefix=true" />
        <camel:to uri="http://localhost:8081/overdraft/getCostmerDetailsAsJSONData/?bridgeEndpoint=true" />
</camel:route>

1 个答案:

答案 0 :(得分:1)

您只需在路径末尾添加setHeader即可设置所需的响应标头。当Camel到达路径的末尾时,它使用当前消息作为响应。

<camel:route trace="true" id="ProxyRepo2"> <camel:from uri="jetty:http://localhost:8299/test?matchOnUriPrefix=true" /> <camel:to uri="http://localhost:8081/overdraft/getCostmerDetailsAsJSONData/?bridgeEndpoint=true" /> <camel:setHeader headerName="foo"> <camel:constant>Hello I was here</camel:constant> </setHeader> </camel:route>

相关问题