43.6. 传递 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 响应代码和文本可作为标头 Exchange.HTTP_RESPONSE_CODE 和 Exchange.HTTP_RESPONSE_TEXT 提供。