Works perfectly.
Thanks again for your advice Mark!!

On 2021/09/24 14:55:22, Alejandro Molinari <alemoli1...@gmail.com> wrote: 
> Good point Mark!
> I'll follow that idea, put the client in a Callable task with the appropriate 
> timeout in the ExecutorService.
> Thanks very much!
> 
> On 2021/09/23 22:23:46, Mark Presling <mark.presl...@argonaut.nz> wrote: 
> > We have had this problem in the past also. Have a look at
> > https://www.baeldung.com/java-executor-service-tutorial
> > 
> > In particular, section 5. You can submit() a Callable task and then use the
> > Future to wait for it to complete, with a timeout...
> > 
> > String result = future.get(20, TimeUnit.SECONDS);
> > 
> > Here, if it takes longer than 20s it will throw an exception and you can
> > handle it as required.
> > 
> > 
> > 
> > On Fri, 24 Sept 2021 at 10:12, Alejandro Molinari <alemoli1...@gmail.com>
> > wrote:
> > 
> > > Hello! I have a simple client to connect a web service destination:
> > >
> > >                 //Obtengo el acceso al servicio.
> > >                 final WsTransaccionOnlineReceptorImplService
> > > wsTOLReceptorImplService = new
> > > WsTransaccionOnlineReceptorImplService(wsdlURL, SERVICE_NAME);
> > >                 //Obtengo el port donde estan definidas las operaciones.
> > >                 final WsTransaccionOnlineReceptor port =
> > > wsTOLReceptorImplService.getWsTransaccionOnlineReceptorPort();
> > >
> > >                 //Asigno los timeouts correspondientes.
> > >                 final Client cliente = ClientProxy.getClient(port);
> > >                 final HTTPConduit http = (HTTPConduit)
> > > cliente.getConduit();
> > >                 final HTTPClientPolicy httpClientPolicy = new
> > > HTTPClientPolicy();
> > >                 //Timeout para la conexion (milisegundos).
> > >                 httpClientPolicy.setConnectionTimeout(3000);
> > >                 //Timeout de recepcion de datos(milisegundos).
> > >                 httpClientPolicy.setReceiveTimeout(10000);
> > >                 http.setClient(httpClientPolicy);
> > >
> > >                 final RespuestaType resp=port.aprobacionTransaccion(tol);
> > >
> > > The ReceiveTimeout works as expected, when no data arrives in the
> > > specified ReceiveTimeout a java.net.SocketTimeoutException: Read timed
> > > out arises.
> > > In some cases when there is network problems or may be the response is in
> > > "chunked transfer encoding" and there is delay between chunks, the 
> > > response
> > > takes minutes to arrive and no exception is thrown (because data is
> > > incoming, but slowly).
> > > This client is embedded in a JAX-WS web service and must return a response
> > > to the caller in certain amount of time and obviously I need an extra
> > > timeout, let's say a "ResponseTimeout".
> > > I tried to start a thread and sleep "ResponseTimeout", after that, call a
> > > cliente.close() if response not arrived completely but has no effect in
> > > blocking mode and i think is not the adequate solution.
> > > Should I use asynchronous  web services to achieve this?
> > > Any suggestion will be appreciated!!
> > > Thanks!
> > >
> > >
> > 
> 

Reply via email to