1

我正在使用 KSOAP2 调用异步 Web 服务(服务器不返回任何内容)。Web 服务调用已经成功,我可以从服务器上看到,但是 HttpTransportSE.call 抛出异常并导致应用程序崩溃。

我的代码是:

envelope.bodyOut = soap;
    envelope.dotNet = false;
    MarshalDouble md = new MarshalDouble();
    md.register(envelope);


        HttpTransportSE androidHttpTransport = new HttpTransportSE(url);
        androidHttpTransport.debug = true;
        try {
            androidHttpTransport.call(null, envelope);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (XmlPullParserException e) {
            e.printStackTrace();
        }

错误日志是:

01-04 17:25:05.930: E/Trace(17787): error opening trace file: No such file or directory (2)
01-04 17:25:06.145: E/SensorManager(17787): thread start
01-04 17:25:19.145: E/AndroidRuntime(17787): FATAL EXCEPTION: AsyncTask #2
01-04 17:25:19.145: E/AndroidRuntime(17787): java.lang.RuntimeException: An error occured while executing doInBackground()
01-04 17:25:19.145: E/AndroidRuntime(17787):    at android.os.AsyncTask$3.done(AsyncTask.java:299)
01-04 17:25:19.145: E/AndroidRuntime(17787):    at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
01-04 17:25:19.145: E/AndroidRuntime(17787):    at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
01-04 17:25:19.145: E/AndroidRuntime(17787):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
01-04 17:25:19.145: E/AndroidRuntime(17787):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
01-04 17:25:19.145: E/AndroidRuntime(17787):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
01-04 17:25:19.145: E/AndroidRuntime(17787):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
01-04 17:25:19.145: E/AndroidRuntime(17787):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
01-04 17:25:19.145: E/AndroidRuntime(17787):    at java.lang.Thread.run(Thread.java:856)
01-04 17:25:19.145: E/AndroidRuntime(17787): Caused by: java.lang.IllegalArgumentException: size <= 0
01-04 17:25:19.145: E/AndroidRuntime(17787):    at java.io.BufferedInputStream.<init>(BufferedInputStream.java:94)
01-04 17:25:19.145: E/AndroidRuntime(17787):    at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:219)
01-04 17:25:19.145: E/AndroidRuntime(17787):    at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:114)
01-04 17:25:19.145: E/AndroidRuntime(17787):    at com.oracle.bpm.mobile.fragment.PSIRFragment.callBPMProcessAcceleratorAdapter(PSIRFragment.java:447)
01-04 17:25:19.145: E/AndroidRuntime(17787):    at com.oracle.bpm.mobile.fragment.PSIRFragment.access$1(PSIRFragment.java:368)
01-04 17:25:19.145: E/AndroidRuntime(17787):    at com.oracle.bpm.mobile.fragment.PSIRFragment$CallPSIRMobileAdapterTask.doInBackground(PSIRFragment.java:364)
01-04 17:25:19.145: E/AndroidRuntime(17787):    at com.oracle.bpm.mobile.fragment.PSIRFragment$CallPSIRMobileAdapterTask.doInBackground(PSIRFragment.java:1)
01-04 17:25:19.145: E/AndroidRuntime(17787):    at android.os.AsyncTask$2.call(AsyncTask.java:287)
01-04 17:25:19.145: E/AndroidRuntime(17787):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
01-04 17:25:19.145: E/AndroidRuntime(17787):    ... 5 more

有人知道为什么吗?如何使用 ksoap 调用异步 Web 服务?谢谢。

4

1 回答 1

0

我检查了 HttpTransportSE.java 的代码,似乎没有办法阻止它获得响应。所以我必须将我的 web 服务更改为同步并返回类似 OK 的内容来解决这个问题。希望 KSOAP2 能解决这个问题。

于 2013-01-05T09:03:30.903 回答