Hi Colm! Thank you so much for your help. I think I've found the problem's root. In completeExchange method (org.apache.cxf.jaxrs.client.AbstractClient class) whenever a redirect is accomplished the state's base URI is modified using the stored retransmit URL. From my understanding it isn't a good idea to do that. I gave a shot to cxf 3.3.1 and the behaviour is the same. :( I could send a patch removing those bits if you think it's the way to go. In the meantime, I think I'm going for a nasty solution... perhaps a well placed interceptor to clean out transport.retransmit.url
Regards! On Wed, May 1, 2019, 5:19 AM Colm O hEigeartaigh <[email protected]> wrote: > I'd recommend trying with a more recent version of CXF to see if it's a bug > that's been fixed subsequent to 3.1.7. > > Colm. > > On Wed, May 1, 2019 at 4:28 AM Pablo Caballero <[email protected]> wrote: > > > Hi community! > > > > cxf version being used: 3.1.7 > > > > - I'm using cxf as a rest client (Proxy based) > > - The server that my client is interacting with returns a 301 (let's > > suposse I can't avoid or circunvent that 301 by any way) > > - At first, the rest invocation was failing with an exception > > - I forced redirects with httpClientPolicy.setAutoRedirect(true) and > > everything worked as expected. Hooray! > > - But soon I realized that requests following the first one were failing > > with 404 Boo Hoo! > > - What I can see is that request following the first one are being > directed > > to a wrong URL > > - I suspect that URL is being "constructed" by CXF from the experience > > gained after the first redirect (in order to avoid networks round trips) > > - Let's see an example: > > > > - First request to > > > > > http://x.x.x.x/QNet24/services/rest/api/datosCheque?cbu=4310001322100000003060&cuit=27237145874&cantidad=10&tipo=CPD > > - Response 301 Location: > > > > > http://x.x.x.x/QNet24/servicesrest/api/datosCheque/?cbu=4310001322100000003060&cuit=27237145874&cantidad=10&tipo=CPD > > - The 301 is honored by CXF and then a 200 response is received. Good! > > > > - Second request to the same interface method > > - URL used: > > > > > http://x.x.x.x/QNet24/servicesrest/api/datosCheque/api/datosCheque?cbu=4310001322100000003060&cbu=4310001322100000003060&cuit=27237145874&cuit=27237145874&cantidad=10&cantidad=10&tipo=CPD&tipo=CPD > > - Notice the "double" api/datosCheque and the duplicated query string > > parameters. > > > > - Moreover if a invoque the other interface method the URL being used is: > > > > > http://x.x.x.x/QNet24/servicesrest/api/datosCheque/api/negociacion?cbu=4310001322100000003060&cuit=27237145874&cantidad=10&tipo=CPD > > (instead of http://x.x.x.x/QNet24/servicesrest/api/negociacion) > > > > Here it is my interface > > > > @Path("/api") > > @Consumes("application/json") > > @Produces("application/json") > > public interface BancoService { > > > > @Path("/datosCheque") > > @GET > > public Response getNumeracion( > > @QueryParam("cbu") String cbu, > > @QueryParam("cuit") String cuit, > > @QueryParam("cantidad") int cantidad, > > @QueryParam("tipo") String tipo); > > > > @Path("/negociacion") > > @POST > > public Response negociacion(NegociacionBanco negociacion); > > > > } > > > > - Is there something I can do to solve this? > > > > - I thought about using apache http client and let it handle the redirect > > stuff but looking at the code (AsyncHTTPConduitFactory) I see that a > > bogus RedirectStrategy is being used and I'm not being able to figure out > > if I could change it (to apache http client DefaultRedirectStrategy for > > example) or I'd mess it up doing so. > > > > Thanks in advance! > > > > Regards! > > > > Pablo > > > > > -- > Colm O hEigeartaigh > > Talend Community Coder > http://coders.talend.com >
