How to decrease the response time of an unsuccessful connection when using Ksoap2?

1

When the server or service (IIS) is off , the web-service response time that there is some connection failure is too long. At that time the application (Android) requests the closure due to inactivity. Can you reduce this time or otherwise treat a possible exception?

public String getTesteConexao(){
    String returns = "";
    try {
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GET_TESTE_CONEXAO);
        request.addProperty("senha", TAG_CHAVE);
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(urlFinal);
        androidHttpTransport.call(SOAP_ACTION, envelope);
        returns = (String) envelope.getResponse();
    } catch (Exception e) {
        e.printStackTrace();
        return "Exception: " + e.getMessage() + "\nCause: " + e.getCause();
    }
    return returns;
}
    
asked by anonymous 02.10.2014 / 14:25

2 answers

1

I found the solution, which by the way is very simple. It was a lack of searching a little more or using the right terms. Just pass as an argument a value in milliseconds on the line

HttpTransportSE androidHttpTransport = new HttpTransportSE(urlFinal, 5000);
    
06.10.2014 / 03:54
0

MSG-TIME_OUT You set response time in milliseconds

    int MSG_TIMEOUT = 15000;
httpTransport = new HttpTransportSE(URL, MSG_TIMEOUT);
    
06.10.2014 / 03:15