如何在调用soap服务时在camel exchange对象中添加HTTP请求头?

时间:2015-07-07 09:24:18

标签: java soap apache-camel soap-client

下面的肥皂服务方面是代码

Map http_headers = (Map) mctx.get(MessageContext.HTTP_REQUEST_HEADERS);
List userList = (List) http_headers.get("Username");
List passList = (List) http_headers.get("Password");

在交换期间,我使用apache camel在客户端添加了代码

Exchange exchangeRequest = lProducerTemplate.request(endpoint,
        new Processor() {
            public void process(Exchange exchange) throws Exception {

                exchange.getIn().setBody(payload);
                exchange.getIn().setHeader(Exchange.HTTP_QUERY, headers);
}});

当我尝试使用wireshark查看数据包时,我发现没有任何内容添加到标题中(肥皂或http)

enter image description here

1 个答案:

答案 0 :(得分:1)

您似乎正在尝试将地图设置为单个标题。我想你可能在寻找

Exchange exchangeRequest = lProducerTemplate.request(endpoint,
    new Processor() {
        public void process(Exchange exchange) throws Exception {

            exchange.getIn().setBody(payload);
            exchange.getIn().setHeaders(headers);
}});