Xilai Dai created CAMEL-12149:
---------------------------------
Summary: Failed to invoke camel cxfrs client due to Content-Type
header couldn't be retrieved and passed
Key: CAMEL-12149
URL: https://issues.apache.org/jira/browse/CAMEL-12149
Project: Camel
Issue Type: Bug
Components: camel-cxfrs
Affects Versions: 2.20.1, 2.19.4
Reporter: Xilai Dai
As of Camel 2.19.x, async support is added by default in the CxfRsProducer.
Considering this simple rsClient:
{code:java}
<camel-cxf:rsClient id="restClient"
address="http://localhost:8040/services/eventlogging/events"
serviceClass="org.talend.esb.eventlogging.sender.rest.EventLogging"
loggingFeatureEnabled="true">
<camel-cxf:providers>
<ref component-id="jsonProvider" />
</camel-cxf:providers>
<camel-cxf:headers>
<entry key="Content-Encoding" value="UTF-8" />
<entry key="Content-Type" value="application/json" />
</camel-cxf:headers>
</camel-cxf:rsClient>
<camel:camelContext>
<camel:route>
<camel:from uri="timer://foo?repeatCount=1" />
<camel:process ref="marshallingPreparationProcessor" />
<camel:to uri="cxfrs://bean://restClient" />
</camel:route>
</camel:camelContext>{code}
It works well with the right Content-Type setting in Camel 2.17.x/Camel.2.18.x,
but the Content-Type will be wildcard and "No message body writer has been
found ..." will be thrown when invoke the restClient in Camel 2.19.x/2.20.x.
{code:java}
----------------------------
ID: 1
Address: http://localhost:8040/services/eventlogging/events
Http-Method: POST
Content-Type: */*
Headers: {Content-Encoding=[UTF-8], Content-Type=[*/*],
Content-Language=[en_US], Accept=[*/*]}
--------------------------------------
[mel-1) thread #0 - timer://foo] CxfRsProducer ERROR Failed
request
javax.ws.rs.ProcessingException: No message body writer has been found for
class org.talend.esb.eventlogging.sender.rest.EventList
, ContentType: */*
at
org.apache.cxf.jaxrs.client.AbstractClient.reportMessageHandlerProblem(AbstractClient.java:810)
at
org.apache.cxf.jaxrs.client.AbstractClient.writeBody(AbstractClient.java:497)
at
org.apache.cxf.jaxrs.client.WebClient$BodyWriter.doWriteBody(WebClient.java:1178)
at
org.apache.cxf.jaxrs.client.AbstractClient$AbstractBodyWriter.handleMessage(AbstractClient.java:1174)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at
org.apache.cxf.jaxrs.client.AbstractClient.doRunInterceptorChain(AbstractClient.java:677)
at
org.apache.cxf.jaxrs.client.WebClient.doInvokeAsync(WebClient.java:952)
at
org.apache.cxf.jaxrs.client.WebClient.doInvokeAsyncCallback(WebClient.java:915)
at
org.apache.cxf.jaxrs.client.WebClient$AsyncInvokerImpl.method(WebClient.java:1440)
at
org.apache.camel.component.cxf.jaxrs.CxfRsProducer.invokeAsyncHttpClient(CxfRsProducer.java:175)
at
org.apache.camel.component.cxf.jaxrs.CxfRsProducer.process(CxfRsProducer.java:116){code}
(https://github.com/xldai/test/tree/master/test-cxfrs is created for easily
reproduce this issue)
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)