54.6. 传递 Salesforce 标头并获取 Salesforce 响应标头
支持通过入站消息标头传递 Salesforce 标头,在请求中以 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 响应状态代码和文本可作为标头 Exchange.HTTP_RESPONSE_CODE 和 Exchange.HTTP_RESPONSE_TEXT 提供。