java.io.EOFException using ksoap2 lib libcore.io.Streams.readAsciiLine(Streams.java:203)

爷,独闯天下 提交于 2019-12-06 11:01:41

This is a bug, I am getting the same error while using ksoap2-android-assembly-3.3.0-jar-with-dependencies.jar. It looks like this problem has been prevailing since v3.1.1 (some users faced this in earlier releases too). A user with gave a workaround to tackle this problem. According to him,

ArrayList<HeaderProperty> headerPropertyArrayList = new ArrayList<HeaderProperty>();
headerPropertyArrayList.add(new HeaderProperty("Connection", "close"));
httpSE.call(SOAP_ACTION, envelope, headerPropertyArrayList);

did the trick. I tried it and it worked for me. If you are still facing the problem then you can use ksoap2-android-assembly-2.6.4-jar-with-dependencies.jar. I am using this version on another project of mine and it has never given me any problems.

I got the same error, but I solved it out, actually soap webservice operation(method) name was misspelled that's why java.io.EOFException Exception was thrown by Ksoap2 library So check your operation(method) name, namespace name and soapAction(name space/method name). I think this will help you to handle this exception

Hi I have faced the same issue.Please use connection time out parameter to avoid this exception.

HttpTransportSE androidHttpTransport = new HttpTransportSE("Your Url here",120000);

and also set connection close parameter in header.

ArrayList<HeaderProperty> headerPropertyArrayList = new ArrayList<HeaderProperty>();
headerPropertyArrayList.add(new HeaderProperty("Connection", "close"));
httpSE.call(SOAP_ACTION, envelope, headerPropertyArrayList);
Vitalii Koren

EOFException - Signals that an end of file or end of stream has been reached unexpectedly during input. This exception is mainly used by data input streams to signal end of stream. Note that many other input operations return a special value on end of stream rather than throwing an exception.

So: after call() your HttpTransportSE instance do instance.getServiceConnection().openOutputStream().close();

MyCode:

HttpTransportSE androidHttpTransport = new HttpTransportSE(url);
try {
    androidHttpTransport.call(mSoapAction, envelope);            
    response = (SoapObject) envelope.bodyIn;

    androidHttpTransport.getServiceConnection().openOutputStream().close();
} catch (IOException | XmlPullParserException e) {
    e.printStackTrace();           
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!