如何使用camel-restlet调用rest服务

如何使用camel-restlet调用rest服务,rest,apache-camel,restlet,Rest,Apache Camel,Restlet,我正在尝试使用restest从camel调用rest服务。 我需要设置一些http头和其他特定于应用程序的头 我就是这样做的: from("timer:50000?repeatCount=1").process(new Processor() { @Override public void process(Exchange exchange) throws Exception { Message out = exchange.getOu

我正在尝试使用restest从camel调用rest服务。 我需要设置一些http头和其他特定于应用程序的头

我就是这样做的:

from("timer:50000?repeatCount=1").process(new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {

            Message out = exchange.getOut();

            Map<String, Object> headers = new HashMap<>();

            headers.put(Exchange.CONTENT_TYPE, "application/json");
            headers.put("token", "value");

            out.setHeaders(headers);
        }
    })
    .to("restlet:https://host:443/api/1/customer?restletMethod=get");
from(“计时器:50000?repeatCount=1”)。进程(新处理器(){
@凌驾
公共作废进程(Exchange)引发异常{
Message out=exchange.getOut();
Map headers=newhashmap();
headers.put(Exchange.CONTENT_TYPE,“application/json”);
标题。放置(“标记”、“值”);
out.setHeaders(headers);
}
})
.to(“restlet”:https://host:443/api/1/customer?restletMethod=get");
但是,生成的http请求根本不应用头


这有什么问题吗?

对于那些可能有同样问题的人,我终于找到了答案。 我不再使用Restlet,而是使用camel-http4

from("timer:50000?repeatCount=1").process(new Processor() {     
        @Override
        public void process(Exchange arg0) throws Exception {
            arg0.getOut().setBody("{ \"login\": \"blabla\", \"secret\":\"blabla\"}");
        }
    })
    .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
    .setHeader("CamelHttpMethod", constant("POST"))
        .to("https4://test:443/rest/")

对于那些可能有同样问题的人,我终于找到了答案。 我不再使用Restlet,而是使用camel-http4

from("timer:50000?repeatCount=1").process(new Processor() {     
        @Override
        public void process(Exchange arg0) throws Exception {
            arg0.getOut().setBody("{ \"login\": \"blabla\", \"secret\":\"blabla\"}");
        }
    })
    .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
    .setHeader("CamelHttpMethod", constant("POST"))
        .to("https4://test:443/rest/")