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

Asked

Viewed 146 times

1

When the server or service (IIS) is off, The web-service response time that there is some connection failure is very long. At this time the application (Android) requests closure due to inactivity. Have to decrease 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;
}
  • I have already found the solution, which by the way is very simple. It was a lack of looking a little more or using the right terms. Just pass as argument a value in milliseconds on the line HttpTransportSE androidHttpTransport = new HttpTransportSE(urlFinal, 5000);

  • 2

    For the question to be in the accepted standards within Sopt, please follow the steps: remove the "SOLVED" part of the title, put your comment as an answer and mark as a solution the answer you put.

  • Rapha, I removed the "solved" from the title and posted your comment as a response (in wiki mode), if you want to publish a reply, let me know and delete what I posted.

  • Tranquil @brasofilo! I just didn’t know how to proceed. Thanks.

2 answers

1

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

HttpTransportSE androidHttpTransport = new HttpTransportSE(urlFinal, 5000);

Originally published as a comment by the author of the question.

0

MSG-TIME_OUT You put the response time in milliseconds

    int MSG_TIMEOUT = 15000;
httpTransport = new HttpTransportSE(URL, MSG_TIMEOUT);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.