我正在尝试使用http://camel.apache.org/http.html上指定的 producertemplate 调用我的简单 GET 休息服务调用。我在这里以 google.com 为例。这是来自未在任何容器上运行的独立客户端。我没有在这里做什么?
SpringCamelContext camelcontext = (SpringCamelContext) springContext.getBean("camelcontextbean");
ProducerTemplate template = camelcontext.createProducerTemplate();
camelcontext.start();
Exchange exchange = template.send("http://www.google.com/search", new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(Exchange.HTTP_QUERY, "hl=en&q=activemq");
}
});
Message out = exchange.getOut();
System.out.println("Response from http template is "+exchange.getOut().getBody());
System.out.println("status header is "+out.getHeader(Exchange.HTTP_RESPONSE_CODE));
我没有得到任何回应。输出是:
来自 http 模板的响应为空
状态标头为空