How to dump HTTP body and headers sent with Apache Camel HTTP component using this route:
from('direct:abc').
setHeader(Exchange.HTTP_URI, constant("${config.gnutch.solr.coreUrl}/select")).
setHeader(Exchange.HTTP_QUERY, constant("q=${q}&wt=xml")).
setHeader(Exchange.CONTENT_TYPE, constant('application/xml')).
setHeader(Exchange.HTTP_METHOD, constant('GET')).
setBody(constant(null)).
to("http://null")
This is Camel DSL code in groovy. Is that possible?
The SetHeader EIP is used for setting a message header.
The http4: component provides HTTP based endpoints for calling external HTTP resources (as a client to call external servers using HTTP).
Camel supports the Message Endpoint pattern using the Endpoint interface. Endpoints are created by a Component and these endpoints are referred to in the DSL via their endpoint URIs.
Have you tried something like
from("direct:abc")
.to("http://domain.com/")
.to("log:DEBUG?showBody=true&showHeaders=true")
Also the HTTP Component Documentation suggests that you can extract the HttpServletRequest
from the exchange like,
HttpServletRequest request = exchange.getIn().getBody(HttpServletRequest.class);
You can then alternatively do,
from("direct:abc").to("http://domain.com").process(new Processor() {
public void process(Exchange exchange) throws Exception {
HttpServletRequest request = exchange.getIn().getBody(HttpServletRequest.class);
// Log request parameters
}
});
This will help , use this in log message :
${headers}
Or
${in.headers}
This will print any incoming headers .
Checkout here : http://camel.apache.org/simple.html
Example :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With