0

I have generated a request for web services. I need to do do a check on my call. If the response is not returned within 5 seconds, another request will be shooted.

Pseudo Code :

webServiceClass response = xyz.getData(); If the response is not obtained in 5 seconds - send another request CheckData() to web services.This should be done for a maximum of 5 times.

I need to do this without using threads.

user3554403
  • 11
  • 1
  • 5

1 Answers1

0

Try something like this (not tested but should give you the idea):

final MultiThreadedHttpConnectionManager httpConnections = new MultiThreadedHttpConnectionManager();
final HttpConnectionManagerParams connParams = manager.getParams();
final HttpClient httpClient = new HttpClient(manager);
final int connectionTimeout = 5000;         
connParams.setConnectionTimeout(connectionTimeout);

    try 
    {
        // your web service call goes here
    }
    catch(ConnectTimeoutException cte)
    {   
        if (isLoggingError())
        {
            logError(cte.getMessage());
        }
    }
    catch(IOException ioe)
    {
        if (isLoggingError())
        {
            logError(ioe.getMessage());
        }
    }
    finally 
    {
        // make sure we always release the connection
        method.releaseConnection();
    }       
bated
  • 960
  • 2
  • 15
  • 29