Search code examples
apache-camel

ApacheCamel - How to get HttpRequest and HttpReponse from exchange after HttpCopoment


How to get HttpRequest and HttpReponse from exchange after HttpCopoment? Any hints or ideas are more than welcome

Below is the code example

        from("direct:restendpoint").routeId("direct_restendpoint")
            .to("https://<URL_SERVICE>")
            .process(exchange -> {
                String responseCode = exchange.getIn().getHeader("CamelHttpResponseCode").toString();
                //How to get httpRequest and httpResponse here?
            })

Solution

  • This is explained in this JIRA: https://issues.apache.org/jira/browse/CAMEL-19077

    HttpServletRequest/Response are only for servlet components, eg camel-servet or camel-jetty and not for HTTP clients. So you cannot get hold of servlet with a HTTP client.