4

我正在使用 SOAP Web 服务开发一个 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

有任何想法吗?解压缩响应时出现问题,但我不知道如何解决。

4

1 回答 1

1

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

HttpTransportSE androidHttpTransport = new HttpTransportSE(this.url,this.connectionTimeout)
于 2013-05-12T10:24:29.420 回答