其他分享
首页 > 其他分享> > Android SOAP IOException“BufferedInputStream已关闭”

Android SOAP IOException“BufferedInputStream已关闭”

作者:互联网

我正在使用SOAP webservices开发一个Android应用程序.当请求的响应太长时,它会在线上给我一个IOException:androidHttpTransport.call(SOAP_ACTION,envelope);

我的代码:

try {
    SoapObject request = new SoapObject(Constants.NAMESPACE, METHOD_NAME);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.encodingStyle = "rpc";
    envelope.setOutputSoapObject(request);

    HttpTransportSE androidHttpTransport = new HttpTransportSE(Constants.WSDL);
    androidHttpTransport.debug = true;

    androidHttpTransport.call(SOAP_ACTION, envelope);

    Object result = (Object)envelope.getResponse();

    String results = result.toString();
    Log.e(TAG, "Result = "+results);
    return parseJson(results);

} catch (Exception e) {
    Log.e(TAG, "Error with SOAP", e);
    Log.e(TAG, e.getMessage());
    return new ArrayList<Route>();
}

例外:

12-03 13:52:56.807: E/RoutesLoader(20272): Error with SOAP
12-03 13:52:56.807: E/RoutesLoader(20272): java.io.IOException: BufferedInputStream is closed
12-03 13:52:56.807: E/RoutesLoader(20272):  at java.io.BufferedInputStream.streamClosed(BufferedInputStream.java:118)
12-03 13:52:56.807: E/RoutesLoader(20272):  at java.io.BufferedInputStream.read(BufferedInputStream.java:279)
12-03 13:52:56.807: E/RoutesLoader(20272):  at java.util.zip.GZIPInputStream.readFully(GZIPInputStream.java:204)
12-03 13:52:56.807: E/RoutesLoader(20272):  at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:98)
12-03 13:52:56.807: E/RoutesLoader(20272):  at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:81)
12-03 13:52:56.807: E/RoutesLoader(20272):  at org.ksoap2.transport.HttpTransportSE.getUnZippedInputStream(HttpTransportSE.java:274)
12-03 13:52:56.807: E/RoutesLoader(20272):  at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:223)
12-03 13:52:56.807: E/RoutesLoader(20272):  at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:114)
12-03 13:52:56.807: E/RoutesLoader(20272):  at eu.akting.bidekide.content.RoutesLoader.downloadRoutes(RoutesLoader.java:51)
12-03 13:52:56.807: E/RoutesLoader(20272):  at eu.akting.bidekide.content.RoutesLoader.loadInBackground(RoutesLoader.java:36)
12-03 13:52:56.807: E/RoutesLoader(20272):  at eu.akting.bidekide.content.RoutesLoader.loadInBackground(RoutesLoader.java:1)
12-03 13:52:56.807: E/RoutesLoader(20272):  at android.support.v4.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:240)
12-03 13:52:56.807: E/RoutesLoader(20272):  at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:51)
12-03 13:52:56.807: E/RoutesLoader(20272):  at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:40)
12-03 13:52:56.807: E/RoutesLoader(20272):  at android.support.v4.content.ModernAsyncTask$2.call(ModernAsyncTask.java:123)
12-03 13:52:56.807: E/RoutesLoader(20272):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
12-03 13:52:56.807: E/RoutesLoader(20272):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
12-03 13:52:56.807: E/RoutesLoader(20272):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
12-03 13:52:56.807: E/RoutesLoader(20272):  at java.lang.Thread.run(Thread.java:856)
12-03 13:52:56.807: E/RoutesLoader(20272): BufferedInputStream is closed

有任何想法吗?
解压缩响应时遇到问题,但我不知道如何修复它.

解决方法:

也许尝试设置非标准超时值.例如:

HttpTransportSE androidHttpTransport = new HttpTransportSE(this.url,this.connectionTimeout)

标签:android,soap,ioexception,ksoap2,android-ksoap2
来源: https://codeday.me/bug/20190709/1412348.html