2017-02-26 100 views
-1

這裏我從客戶端獲取請求,並重定向請求並將響應發送到客戶端。我想添加標題來響應。你可以請指導我,如何添加標題來響應下面提到的代碼。如何在apache駱駝中添加響應標頭

<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

你可以只是在路線的末尾添加setHeader設置你想要的響應頭。當駱駝到達路線的末端時,它將當前消息當作迴應。

<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>