Sorry, instead try:

WebClient.getConfig(wc).getInInterceptors().add(new LoggingInInterceptor());

Colm.

On Tue, Apr 21, 2020 at 5:10 PM masber masber <[email protected]> wrote:

> Hi Colm,
>
> Apparently getInInterceptors is not a WebClient method. IDE forces me to
> cast and then it fails upon execution:
>
> ((InterceptorProvider) wc).getInInterceptors().add(*new*
> LoggingInInterceptor());
>
> Exception:
>
> Apr 22, 2020 2:05:55 AM org.apache.cxf.phase.PhaseInterceptorChain
> doDefaultLogging
>
> WARNING: Application {http://endpoints.mypony.pink/}WarehouseResource has
> thrown exception, unwinding now
>
> org.apache.cxf.interceptor.Fault: org.apache.cxf.jaxrs.client.WebClient
> cannot be cast to org.apache.cxf.interceptor.InterceptorProvider
>
> at org.apache.cxf.service.invoker.AbstractInvoker.createFault(
> AbstractInvoker.java:162)
>
> at org.apache.cxf.service.invoker.AbstractInvoker.invoke(
> AbstractInvoker.java:128)
>
> ------------------------------
> *From:* Colm O hEigeartaigh <[email protected]>
> *Sent:* Tuesday, 21 April 2020 16:13
> *To:* [email protected] <[email protected]>
> *Subject:* Re: how to setup JAX-RS logs programatically
>
> Try:
>
> wc.getInInterceptors().add(new LoggingInInterceptor());
>
> Colm.
>
> On Tue, Apr 21, 2020 at 12:50 AM masber masber <[email protected]> wrote:
>
> > Dear apache cxf user community,
> >
> > how can I setup JAX-RS client logs programmatically in apache CXF? I
> > understand that this is the old way of doing things but still wanted to
> > give it a go. This is my client.
> >
> > I tried using LoggingInInterceptor and LoggingOutInterceptor without
> > success because I could not find the way to add it to the client.
> >
> >
> > List<Object> providers = new ArrayList<Object>();
> > providers.add( new JacksonJaxbJsonProvider() );
> >
> > WebClient wc = WebClient.create(this.base_url,
> > providers).path(this.shipmentsPath).header("account-number",
> > shipment.getContract().getCarrierApiUsername());
> >
> > HTTPConduit conduit = WebClient.getConfig(wc).getHttpConduit();
> > conduit.getClient().setConnectionTimeout(1000 * 5);
> > conduit.getClient().setReceiveTimeout(1000 * 5);
> >
> >
> conduit.getAuthorization().setUserName(shipment.getContract().getCarrierApiUserId());
> >
> >
> conduit.getAuthorization().setPassword(shipment.getContract().getCarrierApiPassword());
> >
> > Response response =
> >
> wc.type(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON_TYPE).post(shipment_payload);
> >
> > any advice?
> >
> > thank you very much
> >
> >
>

Reply via email to