HttpTransportSE gives "java.io.EOFException" error using KSoap2 on Android

2

I'm using the KSoap2 lib in the Android project, for communication with webservice.

All communication is within an AsyncTask ().

In some moments of access to the method, an exception occurs:

"java.io.EOFException"

I searched the Internet and was recommended to include the "Connection / close" property:

[source] link

But even adding, sometimes the error reappears:

HttpTransportSE transport = new HttpTransportSE(WSBase.URL);
try {

        transport.getServiceConnection().setRequestProperty("Connection", "close");

        transport.debug = true;
        transport.call(SOAP_ACTION + methodName, envelope);

        SoapObject response = (SoapObject) envelope.getResponse();

        return new WsRetorno(Integer.parseInt(response.getPropertyAsString("retXml").toString()), 
                response.getPropertyAsString("desRet").toString());

} catch (Exception e) {
    return new WsRetorno(-1, e.getMessage());
}

Someone who has gone through this knows why and how to solve?

    
asked by anonymous 10.07.2014 / 19:27

1 answer

2

Apparently I solved my problem by adding two additional commands to the code:

transport.getServiceConnection().setRequestProperty("Connection", "close");
System.setProperty("http.keepAlive", "false");

Since then he has not made any more mistakes.

    
18.07.2014 / 19:06