Httptransportse gives "java.io.Eofexception" error using Ksoap2 on Android

Asked

Viewed 713 times

2

I am using the lib Ksoap2 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 did an Internet search and was recommended to include the property "Connection/close":

[source] https://groups.google.com/forum/#! msg/ksoap2-android/nwx0MCo4js4/Fyjsxweiekqj

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’s been through it knows why and how to fix it?

1 answer

2


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

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

Since then no more errors presented.

Browser other questions tagged

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