使用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的包不会出现这样的问题。

转载于:https://www.cnblogs.com/jueding920/p/3993268.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值