Source:
public Response populateResteasyRequestFromExchangeAndExecute(String uri, Exchange exchange, Map<String, String> parameters) { Client client = ClientBuilder.newBuilder().build(); String body = exchange.getIn().getBody(String.class); LOG.debug("Body in producer: " + body); String mediaType = exchange.getIn().getHeader(Exchange.CONTENT_TYPE, String.class); WebTarget target = client.target(uri); LOG.debug("Populate Resteasy request from exchange body: using media type {}", body, mediaType); Invocation.Builder builder; if (mediaType != null) { builder = target.request(mediaType); } else { builder = target.request(); } for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (headerFilterStrategy != null && !headerFilterStrategy.applyFilterToCamelHeaders(key, value, exchange)) { builder.header(key, value); LOG.debug("Populate Resteasy request from exchange header: value: {}", key, value); } } if (parameters.get("username") != null && parameters.get("password") != null) { target.register(new BasicAuthentication(parameters.get("username"), parameters.get("password"))); } LOG.debug("Basic authentication was applied"); String method = parameters.get("method"); if (method.equals("GET")) { return builder.get(); } if (method.equals("POST")) { return builder.post(Entity.entity(body, mediaType)); } if (method.equals("PUT")) { return builder.put(Entity.entity(body, mediaType)); } if (method.equals("DELETE")) { return builder.delete(); } if (method.equals("OPTIONS")) { return builder.options(); } if (method.equals("TRACE")) { return builder.trace(); } if (method.equals("HEAD")) { return builder.head(); } throw new IllegalArgumentException("Method '" + method + "' is not supported method"); }

Target:
public Response populateResteasyRequestFromExchangeAndExecute(String uri, Exchange exchange, Map<String, String> parameters) { Client client = ClientBuilder.newBuilder().build(); String body = exchange.getIn().getBody(String.class); LOG.debug("Body in producer: {}", body); String mediaType = exchange.getIn().getHeader(Exchange.CONTENT_TYPE, String.class); WebTarget target = client.target(uri); LOG.debug("Populate Resteasy request from exchange body: using media type {}", body, mediaType); Invocation.Builder builder; if (mediaType != null) { builder = target.request(mediaType); } else { builder = target.request(); } for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (headerFilterStrategy != null && !headerFilterStrategy.applyFilterToCamelHeaders(key, value, exchange)) { builder.header(key, value); LOG.debug("Populate Resteasy request from exchange header: value: {}", key, value); } } if (parameters.get("basicAuth") != null && Boolean.TRUE.equals(ObjectHelper.cast(Boolean.class, parameters.get("basicAuth")))) { if (parameters.get("username") != null && parameters.get("password") != null) { target.register(new BasicAuthentication(parameters.get("username"), parameters.get("password"))); LOG.debug("Basic authentication was applied"); } } String method = parameters.get("method"); if (method.equals("GET")) { return builder.get(); } if (method.equals("POST")) { return builder.post(Entity.entity(body, mediaType)); } if (method.equals("PUT")) { return builder.put(Entity.entity(body, mediaType)); } if (method.equals("DELETE")) { return builder.delete(); } if (method.equals("OPTIONS")) { return builder.options(); } if (method.equals("TRACE")) { return builder.trace(); } if (method.equals("HEAD")) { return builder.head(); } throw new IllegalArgumentException("Method '" + method + "' is not supported method"); }