使用ksoap2报java.io.EOFException异常问题解决方法
使用ksoap2调用WebService数据读取正常,但一直报异常:
java.io.EOFException at libcore.io.Streams.readAsciiLine(Streams.java:203) at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:560) at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:813) at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:274) at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:486) at org.ksoap2.transport.ServiceConnectionSE.getResponseCode(ServiceConnectionSE.java:103) at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:197) at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:118) at .utils.Webservices.callinternet(Webservices.java:125) at .utils.Webservices.getResponse(Webservices.java:73) at .utils.Webservices.getResponse(Webservices.java:79) at .utils.Webservices.getResponse(Webservices.java:79) at .utils.AsynTask.doInBackground(AsynTask.java:61) at .utils.AsynTask.doInBackground(AsynTask.java:1) at android.os.AsyncTask$2.call(AsyncTask.java:287) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) at java.util.concurrent.FutureTask.run(FutureTask.java:137) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) at java.lang.Thread.run(Thread.java:856)
解决方法1
ArrayList<HeaderProperty> headerPropertyArrayList = new ArrayList<HeaderProperty>(); headerPropertyArrayList.add(new HeaderProperty("Connection", "close")); httpSE.call(SOAP_ACTION, envelope, headerPropertyArrayList);
加上红色部分代码就解决了。
解决方法2
使用 ksoap2-android-assembly-2.6.4-jar-with-dependencies.jar这个版本的ksoap2的包不会出现这样的问题。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。