Hi souciance, Below is the complete test case I have written to debug this problem. You can import and fix the 'package' and 'logger' to remove errors. 'createRouteBuilder' method at the end has the two routes using camel-http and camel-http4. The URLs are constants.
I am using the SAP Cloud Identity API [1] which expects Content-Type: application/scim+json. But if this is not given then it works fine. In case of camel-http4 we get 'text/plain' by default. Can't provide credential, you may be able to debug to see the 'Content Type' getting set with Camel-Http4 and not getting with Camel-Http Right now my need is to just make it empty like Camel-http. We HAD to move to camel-http4 because of SSL support. And now this one use-case isn't working :( Regards, Arpit. [1] - https://help.sap.com/viewer/6d6d63354d1242d185ab4830fc04feb1/Cloud/en-US/2f215687fcf34170b0bbc8b36b60f2e9.html Complete test case import org.apache.camel.CamelContext; import org.apache.camel.EndpointInject; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.Produce; import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.direct.DirectEndpoint; import org.apache.camel.http.common.HttpOperationFailedException; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.impl.DefaultExchange; import org.apache.camel.impl.SimpleRegistry; import org.apache.camel.testng.CamelTestSupport; import org.testng.annotations.Test; public class TestSCIMScenario extends CamelTestSupport { static { System.setProperty("javax.net.debug", "all"); System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true"); System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http", "DEBUG"); } @EndpointInject(uri = "direct:startHttp") protected DirectEndpoint startHttp; @EndpointInject(uri = "direct:startHttp4") protected DirectEndpoint startHttp4; @Produce(uri = "direct:start") protected ProducerTemplate producer; /* Payload based on SAP Cloud Indentity REST API - https://help.sap.com/viewer/6d6d63354d1242d185ab4830fc04feb1/Cloud/en-US/2f215687fcf34170b0bbc8b36b60f2e9.html */ private static final String SCIM_PAYLOAD = "{\r\n \"userName\": \"alexAderson\",\r\n \"name\": {\r\n \"givenName\": \"Alex\",\r\n \"familyName\": \"Anderson\",\r\n \"honorificPrefix\": \"Mr.\"\r\n },\r\n \"emails\": [\r\n {\r\n \"value\": \"[email protected]\"\r\n }\r\n ],\r\n \"addresses\": [\r\n {\r\n \"type\": \"home\",\r\n \"streetAddress\": \"1029 East River Drive\",\r\n \"locality\": \"Street 301\",\r\n \"region\": \"CA\",\r\n \"postalCode\": \"94401\"\r\n }\r\n ],\r\n \"phoneNumbers\": [],\r\n \"displayName\": \"nosample\",\r\n \"company\": \"YYY_USA\",\r\n \"active\": true\r\n}"; /* Camel-Http4 based URL */ private static final String http4Endpoint = "https4://<tenant ID>.ondemand.com/service/scim/Users?proxyAuthHost=ppppp&proxyAuthPort=8888&proxyAuthScheme=http4&authUsername=xxxxxx&authPassword=yyyyy&httpClientConfigurer=#customConfigurer"; /* Camel-Http based URL */ private static final String httpEndpoint = "https://<tenant ID>.ondemand.com/service/scim/Users?proxyHost=ppppp&proxyPort=8888&authUsername=xxxxxx&authPassword=yyyyy&authMethod=Basic"; private static final Logger LOG = LogManager.getLogger(); @Test public void testSCIMHttp() throws Exception { DefaultExchange request = (DefaultExchange) producer.request(startHttp, new Processor() { @Override public void process(Exchange exchange) throws Exception { } }); if (request.getException() != null) { throw request.getException(); } } @Test public void testSCIMHttp4() throws Exception { DefaultExchange request = (DefaultExchange) producer.request(startHttp4, new Processor() { @Override public void process(Exchange exchange) throws Exception { } }); if (request.getException() != null) { throw request.getException(); } } protected CamelContext createCamelContext() throws Exception { SimpleRegistry registry = new SimpleRegistry(); registry.put("customConfigurer", new CustomHttpClientConfigurer()); CamelContext cc = new DefaultCamelContext(registry); return cc; } @Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { onException(Exception.class).process(new Processor() { @Override public void process(Exchange exchange) throws Exception { Exception exception = null; if (exchange != null && exchange.getProperty(CAMEL_PROPERTY_EXCEPTION_CAUGHT) instanceof Exception) { exception = (Exception) exchange.getProperty(CAMEL_PROPERTY_EXCEPTION_CAUGHT); } if (exception instanceof HttpOperationFailedException) { HttpOperationFailedException ex = (HttpOperationFailedException) exception; LOG.info("*********************HTTP FAILED BEGIN*********************"); LOG.info("Status Code " + ex.getStatusCode() + " Status Text " + ex.getStatusText() + " Response Body " + ex.getResponseBody()); LOG.info("*********************HTTP FAILED END*********************"); } if(exception != null) { throw exception; } } }); from(startHttp).setBody().constant(SCIM_PAYLOAD).to(httpEndpoint).process(new Processor() { @Override public void process(Exchange exchange) throws Exception { LOG.info("*********************HTTP SUCCESS BEGIN*********************"); LOG.info(exchange.getIn().getBody(String.class)); LOG.info("*********************HTTP SUCCESS END*********************"); } }); from(startHttp4).setBody().constant(SCIM_PAYLOAD).setHeader(Exchange.CONTENT_TYPE).constant(null).to(http4Endpoint); } }; } } -----Original Message----- From: souciance [mailto:[email protected]] Sent: Tuesday, April 4, 2017 10:34 PM To: [email protected] Subject: Re: Camel Http vs Camel Http4 - Content Type Header Can you share your entire route code? Den 5 apr. 2017 5:25 fm skrev "Goyal, Arpit [via Camel]" < [email protected]>: > Anyone else has idea of this camel logic? > > Sent from my iPhone > > > On Apr 3, 2017, at 4:33 PM, Goyal, Arpit <[hidden email] > <http:///user/SendEmail.jtp?type=node&node=5796938&i=0>> wrote: > > > > Hi Claus, > > > > HttpProduce -- from camel-http4 library is setting the content-type > 'text/plain' in method [1] line # 488 (camel version 2.16.3) even though > we have set the Content-Type to be NULL - This is NOT the case with > HttpProducer - from camel-http library. > > > > By enabling the apache commons log, the headers are clearly visible. > > > > The end-system we are invoking throws '415' due to the wrong Content > Type passed and if we DO NOT pass any content type it works. As at > execution time we can't determine the Content-Type, we want to pass it > NULL. > > > > Any possible way to achieve not sending of Content-Type header? > > > > 2017/04/04 00:48:55:618 CEST [DEBUG] headers - http-outgoing-0 >> POST > /service/scim/Users HTTP/1.1 > > 2017/04/04 00:48:55:618 CEST [DEBUG] headers - http-outgoing-0 >> > breadcrumbId: ID-i044312-33503-1491259732621-0-1 > > 2017/04/04 00:48:55:618 CEST [DEBUG] headers - http-outgoing-0 >> > Content-Length: 518 > > 2017/04/04 00:48:55:618 CEST [DEBUG] headers - http-outgoing-0 >> > Content-Type: text/plain ---- in this line. > > 2017/04/04 00:48:55:618 CEST [DEBUG] headers - http-outgoing-0 >> Host: > xxxxxxx > > 2017/04/04 00:48:55:618 CEST [DEBUG] headers - http-outgoing-0 >> > Connection: Keep-Alive > > 2017/04/04 00:48:55:618 CEST [DEBUG] headers - http-outgoing-0 >> > User-Agent: Apache-HttpClient/4.5.2 (Java/1.7.0_101) > > 2017/04/04 00:48:55:618 CEST [DEBUG] headers - http-outgoing-0 >> > Accept-Encoding: gzip,deflate > > 2017/04/04 00:48:55:618 CEST [DEBUG] headers - http-outgoing-0 >> > Authorization: Basic XXXXXXXX > > 2017/04/04 00:48:55:619 CEST [DEBUG] wire - http-outgoing-0 >> "POST > /service/scim/Users HTTP/1.1[\r][\n]" > > 2017/04/04 00:48:55:619 CEST [DEBUG] wire - http-outgoing-0 >> > "breadcrumbId: ID-i044312-33503-1491259732621-0-1[\r][\n]" > > 2017/04/04 00:48:55:619 CEST [DEBUG] wire - http-outgoing-0 >> > "Content-Length: 518[\r][\n]" > > 2017/04/04 00:48:55:619 CEST [DEBUG] wire - http-outgoing-0 >> > "Content-Type: text/plain[\r][\n]" --- in this line > > 2017/04/04 00:48:55:619 CEST [DEBUG] wire - http-outgoing-0 >> "Host: > xxxxxxxxx[\r][\n]" > > 2017/04/04 00:48:55:619 CEST [DEBUG] wire - http-outgoing-0 >> > "Connection: Keep-Alive[\r][\n]" > > 2017/04/04 00:48:55:619 CEST [DEBUG] wire - http-outgoing-0 >> > "User-Agent: Apache-HttpClient/4.5.2 (Java/1.7.0_101)[\r][\n]" > > 2017/04/04 00:48:55:619 CEST [DEBUG] wire - http-outgoing-0 >> > "Accept-Encoding: gzip,deflate[\r][\n]" > > 2017/04/04 00:48:55:619 CEST [DEBUG] wire - http-outgoing-0 >> > "Authorization: Basic XXXXXXXX[\r][\n]" > > 2017/04/04 00:48:55:619 CEST [DEBUG] wire - http-outgoing-0 >> > "[\r][\n]" > > 2017/04/04 00:48:55:619 CEST [DEBUG] wire - http-outgoing-0 >> > "{[\r][\n]" > > 2017/04/04 00:48:55:620 CEST [DEBUG] wire - http-outgoing-0 >> "}" > > > > [1] - > > org.apache.camel.component.http4.HttpProducer.createRequestEntity(Exchange) > > > > > Regards, > > Arpit. > > > > > > -----Original Message----- > > From: souciance [mailto:[hidden email] > <http:///user/SendEmail.jtp?type=node&node=5796938&i=1>] > > Sent: Thursday, February 9, 2017 1:40 PM > > To: [hidden email] > <http:///user/SendEmail.jtp?type=node&node=5796938&i=2> > > Subject: Re: Camel Http vs Camel Http4 - Content Type Header > > > > Well it should be pretty easy to setup a http server and see what > headers > > your route are sending and compare that to what the actual server wants. > If > > camel-http4 is suppressing some headers then perhaps try another > component. > > > > On Thu, Feb 9, 2017 at 10:32 PM, Goyal, Arpit [via Camel] < > > [hidden email] <http:///user/SendEmail.jtp?type=node&node=5796938&i=3>> > wrote: > > > >> Hi, > >> > >> We were on Camel-Http (2.16) and moving to Camel-Http4 (2.16) and saw > that > >> URL which worked with Camel-http now fails with Camel-Http4 with status > >> code - 415 (Unsupported Media Type). > >> > >> Caused by: org.apache.camel.http.common.HttpOperationFailedException: > >> HTTP operation failed invoking https://<host>:<port>/ > >> myservice/Users?authMethod=Basic with statusCode: 415 > >> > >> Saw this discussion on Nabble - http://camel.465427.n5.nabble. > >> com/Http4-Set-Header-Content-Type-not-passing-through-to- > >> the-HTTP-Request-td5746414.html#a5752856 > >> > >> Does this mean we CAN"T USE - Camel-HTTP4 ? > >> > >> Regards, > >> Arpit. > >> > >> > >> ------------------------------ > >> If you reply to this email, your message will be added to the > discussion > >> below: > >> http://camel.465427.n5.nabble.com/Camel-Http-vs-Camel-Http4- > >> Content-Type-Header-tp5793736.html > >> To start a new topic under Camel - Users, email > >> [hidden email] <http:///user/SendEmail.jtp?type=node&node=5796938&i=4> > >> To unsubscribe from Camel - Users, click here > >> < > >> . > >> NAML > >> <http://camel.465427.n5.nabble.com/template/ > NamlServlet.jtp?macro=macro_viewer&id=instant_html% > 21nabble%3Aemail.naml&base=nabble.naml.namespaces. > BasicNamespace-nabble.view.web.template.NabbleNamespace- > nabble.view.web.template.NodeNamespace&breadcrumbs= > notify_subscribers%21nabble%3Aemail.naml-instant_emails% > 21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > >> > > > > > > > > > > -- > > View this message in context: http://camel.465427.n5.nabble. > com/Camel-Http-vs-Camel-Http4-Content-Type-Header-tp5793736p5793737.html > > Sent from the Camel - Users mailing list archive at Nabble.com. > > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > http://camel.465427.n5.nabble.com/Camel-Http-vs-Camel-Http4- > Content-Type-Header-tp5793736p5796938.html > To start a new topic under Camel - Users, email > [email protected] > To unsubscribe from Camel - Users, click here > <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=> > . > NAML > <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > -- View this message in context: http://camel.465427.n5.nabble.com/Camel-Http-vs-Camel-Http4-Content-Type-Header-tp5793736p5796944.html Sent from the Camel - Users mailing list archive at Nabble.com.
