Hi,

Could you please append a reproducer project so that I can take a close look?

Freeman
-------------
Freeman(Yue) Fang

Red Hat, Inc. 





> On Jul 10, 2019, at 3:06 AM, Zoltán Balogh <[email protected]> wrote:
> 
> thanks for your answer but now I'm totally confused...
> If I set CamelCxfRsUsingHttpAPI to true the getKodtarElemListByType
> works properly.
> But in this case I got exception for
>    @POST
>    public Response createKodtarElem(KodtarDto dto);
> 
> 08:49:11,874 SEVERE [org.apache.cxf.jaxrs.utils.JAXRSUtils] (default
> task-10) No message body writer has been found for class
> hu.fornax.tua.kodtar.dto.KodtarDto, ContentType: application/xml
> 08:49:11,875 WARNING [org.apache.cxf.phase.PhaseInterceptorChain]
> (default task-10) Interceptor for
> {http://localhost:8080/tua-kodtar/rest}WebClient has thrown exception,
> unwinding now: org.apache.cxf.interceptor.Fault: No message body
> writer has been found for class hu.fornax.tua.kodtar.dto.KodtarDto,
> ContentType: application/xml
> 
> The json provider is set (&providers=#jsonProvider), I have tried with
> JacksonJaxbJsonProvider and with JacksonJsonProvider as well
> 
> If I set CamelCxfRsUsingHttpAPI to false the @Post works. Otherwise
> getting NPE to the @GET as I wrote in my first mail.
> 
> I want only to proxy rest request to an other service where a cxfrs
> rest endpoint consume, please help me how I can solve it?
> 
> Thanks again your support!
> 
> 
> 
> 
> 
> 
> 
> Freeman Fang <[email protected]> ezt írta (időpont: 2019. júl.
> 9., K, 19:33):
>> 
>> Hi,
>> 
>> The difference with camel-cxf proxy is that you have 
>> setHeader("CamelCxfRsUsingHttpAPI", constant("false”)) in the route, which 
>> means you will use proxy client to invoke the RS server, so the para types 
>> must match the one in resourceClasses, without camel-cxf proxy you actually 
>> use http client. If you have setHeader("CamelCxfRsUsingHttpAPI", 
>> constant(“true”)) in your router the behaviour should be same with or 
>> without proxy.
>> 
>> So if you have setHeader("CamelCxfRsUsingHttpAPI", constant("false”)) , 
>> ensure you have all parameters available in the payload.
>> 
>> I think we probably can enhance here a bit, instead of throw NPE, throwing 
>> NoSuchMethodException if can’t find match method in the client proxy.
>> -------------
>> Freeman(Yue) Fang
>> 
>> Red Hat, Inc.
>> 
>> 
>> 
>> 
>> 
>>> On Jul 9, 2019, at 7:32 AM, Zoltán Balogh <[email protected]> wrote:
>>> 
>>> Hi,
>>> 
>>> why the cxfrs producer not accept null query params? Should I set an
>>> additional parameter to pass null value?
>>> 
>>> My route:
>>>       from("cxfrs:http://localhost:8080/tua";
>>>               + "?resourceClasses="
>>>               + "hu.fornax.tua.kodtar.protocol.rest.KodtarREST"
>>>               + "&loggingFeatureEnabled=true"
>>>               + "&providers=#jsonProvider")
>>>                       .removeHeader("Content-Type")
>>>                       .setHeader("CamelCxfRsUsingHttpAPI", 
>>> constant("false"))
>>>                       .log(ESBLog.ESB + "REST request: ${headers}")
>>>                       .to("cxfrs:http://localhost:8080/tua-kodtar/rest";
>>>                               +
>>> "?resourceClasses=hu.fornax.tua.kodtar.protocol.rest.KodtarREST&throwExceptionOnFailure=false&loggingFeatureEnabled=true&providers=#jsonProvider")
>>>                       .otherwise()
>>> 
>>> The rest interface:
>>> 
>>>   @Path("/{type}")
>>>   public List<KodtarDto> getKodtarElemListByType(@PathParam("type")
>>> KodtarType type, @QueryParam("id") Long id);
>>> 
>>> If I call the consumer (cxfrs://http://localhost:8080/tua) to proxy the 
>>> request:
>>> 
>>> 13:23:34,882 ERROR [org.apache.camel.processor.DefaultErrorHandler]
>>> (default task-2) Failed delivery for (MessageId:
>>> ID-DESKTOP-A2U86J9-59663-1562671187095-11-1 on ExchangeId:
>>> ID-DESKTOP-A2U86J9-59663-1562671187095-11-2). Exhausted after delivery
>>> attempt: 1 caught: java.lang.NullPointerException
>>> 
>>> Message History
>>> ---------------------------------------------------------------------------------------------------------------------------------------
>>> RouteId              ProcessorId          Processor
>>>                                                   Elapsed (ms)
>>> [route15           ] [route15           ]
>>> [cxfrs://http://localhost:8080/tua?loggingFeatureEnabled=true&providers=%23json]
>>> [        65]
>>> [route15           ] [removeHeader1     ] [removeHeader[Content-Type]
>>>                                                 ] [         1]
>>> [route15           ] [setHeader3        ]
>>> [setHeader[CamelCxfRsUsingHttpAPI]
>>>       ] [         0]
>>> [route15           ] [log31             ] [log
>>>                                                 ] [         3]
>>> [route15           ] [log32             ] [log
>>>                                                 ] [         1]
>>> [route15           ] [choice3           ]
>>> [when[{header{header(CamelHttpUri)} contains
>>> /tua/api/file}]choice[when[{header] [        54]
>>> [route15           ] [to8               ]
>>> [cxfrs:http://localhost:8080/tua-kodtar/rest?resourceClasses=hu.fornax.tua.kodt]
>>> [        49]
>>> 
>>> Stacktrace
>>> ---------------------------------------------------------------------------------------------------------------------------------------:
>>> java.lang.NullPointerException
>>> at 
>>> org.apache.camel.component.cxf.jaxrs.CxfRsProducer.getParameterTypes(CxfRsProducer.java:524)
>>> at 
>>> org.apache.camel.component.cxf.jaxrs.CxfRsProducer.invokeProxyClient(CxfRsProducer.java:430)
>>> at 
>>> org.apache.camel.component.cxf.jaxrs.CxfRsProducer.process(CxfRsProducer.java:103)
>>> at 
>>> org.apache.camel.impl.SynchronousDelegateProducer.process(SynchronousDelegateProducer.java:62)
>>> at 
>>> org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
>>> at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)
>>> at 
>>> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
>>> at 
>>> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:541)
>>> at 
>>> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198)
>>> at 
>>> org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:117)
>>> at 
>>> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
>>> at 
>>> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:541)
>>> at 
>>> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198)
>>> at org.apache.camel.processor.Pipeline.process(Pipeline.java:120)
>>> at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
>>> at 
>>> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198)
>>> at 
>>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:97)
>>> at 
>>> org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.syncInvoke(CxfRsInvoker.java:139)
>>> at 
>>> org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.performInvocation(CxfRsInvoker.java:72)
>>> 
>>> 
>>> If the queryparam is set with value that is not null the route works
>>> and calling the service consumer directly without adding "id" it works
>>> as well (cxfrs:http://localhost:8080/tua-kodtar/rest)....
>>> If I want to proxy the request getting NullPointerException.
>>> env: WildFly-Camel 4.9.0
>>> 
>>> Thanks for your help!
>>> Topicfun
>> 

Reply via email to