Ok. I was able to figure this out.

Changed my code to:

Exchange response = template.send(endpoint, new
HttpOutboundProcessor(exchange.getOut().getBody().toString()));
Integer responseCode =
(Integer)response.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE);
String responseBody =
IOUtils.toString((InputStream)response.getOut().getBody());

And that seems to work. I created a new, local, HttpOutboundProcessor class:

public class HttpOutboundProcessor implements Processor {

    private String exchangeBody;

    public HttpOutboundProcessor(String exchangeBody) {
        this.exchangeBody = exchangeBody;
    }

    @Override
    public void process(Exchange exchange) throws Exception {
        exchange.getIn().setHeader(Exchange.HTTP_METHOD, "POST");
        exchange.getIn().setBody(exchangeBody);
    }
}

Thank you for the help.


P.S. I tried replacing the whole exchange in the "process" method, but that
caused issues.



--
View this message in context: 
http://camel.465427.n5.nabble.com/HTTP-POST-with-ProducerTemplate-tp5785366p5785448.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to