[ 
https://issues.apache.org/jira/browse/CXF-7459?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Colm O hEigeartaigh closed CXF-7459.
------------------------------------

> JAX-RS WebClient.invoke() do not respect Content-Type setting in HTTP-Conduit
> -----------------------------------------------------------------------------
>
>                 Key: CXF-7459
>                 URL: https://issues.apache.org/jira/browse/CXF-7459
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 3.1.5
>            Reporter: Luke Xu
>            Assignee: Sergey Beryozkin
>             Fix For: 3.1.13, 3.2.0
>
>
> Hi,
> We got in some problem while using WebClient.invoke() to communicate external 
> services.
> The message sent by WebClient.invoke() comes from other part of our product, 
> which plays the role of an integrator basing on configuration. Thus during 
> development, we can't know the real type of message and set all message type 
> in the invoke method as inputStream. Other information of the connection for 
> example Content-Type is set in http-conduit.
> The problem we found is that under our usage of WebClient.invoke(), 
> Content-Type in http-conduit can't be set to 
> application/x-www-form-urlencoded. It is set back to default value 
> application/xml as is WebClient. But it is not true for other type of 
> Content-Type setting in conduit. To set ourselves' headers object to the 
> WebClient before invoking it bypasses the issue as well.
> Another problem is logging feature lies on this issue. 
> application/x-www-form-urlencoded is showed in log but if monitoring with 
> third part tool it's application/xml.
> Related configuration xml:
> {quote}
>     <http:conduit name="*.http-conduit">
>         <http:client AutoRedirect="false" AllowChunking="false" Accept="*/*" 
> ContentType="application/x-www-form-urlencoded"/>
>     </http:conduit>
>     <cxf:bus>
>         <cxf:features>
>             <cxf:logging/>
>         </cxf:features>
>     </cxf:bus>
> {quote}
> Sample code of our product to call service.
> {quote}
>         if (webClientTemplate == null) \{
>             // create from the url and provider list
>             webClientTemplate = WebClient.create(address, providerList);
>             // copy the headers over
>             MultivaluedMap<String, String> tempHeaders = 
> webClientTemplate.getHeaders();
>             for (String key : headers.keySet()) \{
>                 String value = headers.get(key);
>                 tempHeaders.putSingle(key, value);
>             }
>             webClientTemplate.headers(tempHeaders);
>         }
>         // now we always have a template, copy it for best speed in creating 
> a web client
>         return WebClient.fromClient(webClientTemplate, true);
>         ......
>         responseStream = webClient.invoke(requestMethod, requestStream, 
> InputStream.class);
> {quote}
> Comparing logging we got between old version and 3.1.5 we are in use.
> {quote}
> Working (2.7.8):
>  
> INFO: Outbound Message
> ---------------------------
> ID: 1
> Address: https://developer.tigertext.me/v2/message
> Http-Method: POST
> Content-Type: application/x-www-form-urlencoded
> Headers: \{Content-Type=\[application/xml], Accept=\[*/*], 
> Authorization=\[Basic 
> VFF3Y1ZUOXljaHpFVG93bkVTUVpxc3g2cm9oaE5yUDU6V1lUeGpDUzgwTEF6YWFTOWNyRFp3QlhTZnRjRmxmb1JBMDFHbW9MUFpwZUJxbG14],
>  Connection=\[Keep-Alive]}
> Payload: recipient=%2B15739992640&ttl=1440&body=Patient Test, ADM (DOB: 
> 19650414) has been admitted to Stamford Hospital and indicated you as their 
> PCP.
> --------------------------------------
>  
> INFO: Inbound Message
> ----------------------------
> ID: 1
> Response-Code: 204
> Encoding: ISO-8859-1
> Content-Type: application/json
> Headers: \{connection=\[keep-alive], Content-Length=\[0], 
> content-type=\[application/json], Date=\[Wed, 26 Jul 2017 21:04:48 GMT], 
> Server=\[nginx], TT-X-Message-Id=\[67e0fa88-4965-41a7-a37a-97ec0280d4ec], 
> TT-X-Msg-Ttl=\[1440], 
> TT_Log_Account_Token=\[d7d6b87c-1ccd-4ad1-bc2b-40f2d4d28e1d], 
> TT_Log_API_Key=\[16675b77-a1d7-4815-96e4-9802254cb3f3], 
> TT_Log_HTTP_Verb=\[POST], 
> TT_Log_Message_ID=\[67e0fa88-4965-41a7-a37a-97ec0280d4ec], 
> TT_Log_Organization=\[agbdTQbwmlqiasaI2zkPLFO2], 
> TT_Log_Processed_By_Host=\[prod-tigerconnect-xmpp-i-08fc29d0a5e5715a2], 
> TT_Log_Product_Token=\[consumer], TT_Log_Traffic_Type=\[public], 
> TT_Log_URI_Name=\[/api/message/message_id]}
> --------------------------------------
>  
>  
> Not working (3.1.5):
>  
> INFO: Outbound Message
> ---------------------------
> ID: 1
> Address: https://developer.tigertext.me/v2/message
> Http-Method: POST
> Content-Type: application/x-www-form-urlencoded
> Headers: \{Content-Type=\[application/xml], Accept=\[*/*], 
> Authorization=\[Basic 
> VFF3Y1ZUOXljaHpFVG93bkVTUVpxc3g2cm9oaE5yUDU6V1lUeGpDUzgwTEF6YWFTOWNyRFp3QlhTZnRjRmxmb1JBMDFHbW9MUFpwZUJxbG14],
>  Connection=\[Keep-Alive]}
> Payload: recipient=%2B15739992640&ttl=1440&body=Patient Test, ADM (DOB: 
> 19650414) has been admitted to Stamford Hospital and indicated you as their 
> PCP.
> --------------------------------------
>  
> INFO: Inbound Message
> ----------------------------
> ID: 1
> Response-Code: 415
> Encoding: ISO-8859-1
> Content-Type: application/json
> Headers: \{connection=\[keep-alive], Content-Length=\[0], 
> content-type=\[application/json], Date=\[Wed, 26 Jul 2017 20:56:48 GMT], 
> Server=\[nginx], 
> TT_Log_Account_Token=\[d7d6b87c-1ccd-4ad1-bc2b-40f2d4d28e1d], 
> TT_Log_API_Key=\[16675b77-a1d7-4815-96e4-9802254cb3f3], 
> TT_Log_HTTP_Verb=\[POST], TT_Log_Organization=\[agbdTQbwmlqiasaI2zkPLFO2], 
> TT_Log_Processed_By_Host=\[prod-tigerconnect-xmpp-i-08fc29d0a5e5715a2], 
> TT_Log_Product_Token=\[consumer], TT_Log_Traffic_Type=\[public], 
> TT_Log_URI_Name=\[/api/message/message_id]}
> --------------------------------------
> {quote}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to