简体   繁体   中英

How to add HTTP request header in camel exchange object while calling soap service?

At soap service side below is the code

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

During exchange the code I have added at the client using 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);
}});

When I tried to see packet using wireshark I see that nothing gets added to the header(both soap or http)

在此处输入图片说明

It appears you are trying to set a map to a single header. I think you may be looking for

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM