103.7. 传递 Salesforce 标头并获取 Salesforce 响应标头
支持通过入站 消息标头传递 Salesforce 标头,从 Camel 消息上的 Sforce 或 x-sfdc 开始的标头将在请求中传递,以及以 Sforce 开头的响应标头将出现在出站消息标头中。
例如,要获取 API 限制,您可以指定:
// in your Camel route set the header before Salesforce endpoint
//...
.setHeader("Sforce-Limit-Info", constant("api-usage"))
.to("salesforce:getGlobalObjects")
.to(myProcessor);
// myProcessor will receive `Sforce-Limit-Info` header on the outbound
// message
class MyProcessor implements Processor {
public void process(Exchange exchange) throws Exception {
Message in = exchange.getIn();
String apiLimits = in.getHeader("Sforce-Limit-Info", String.class);
}
}
另外,HTTP 响应状态代码和文本作为标头 交换。HTTP_RESPONSE_CODE 和 Exchange.HTTP_RESPONSE_TEXT 提供。