我正在使用支持超时的 ksoap2 2.5.4(在 Android 2.2 上)。我正在使用 Apache 2.2.16 来处理我的请求。一切正常,但是当我关闭我的 Apache(或断开运行 Apache 的远程 PC)时,调用永远不会超时。我正在使用单独的线程来调用我的 WS,在这种情况下,该线程停止工作/响应/停止大约 2 分钟。
int MSG_TIMEOUT = 15000;
HttpTransportSE httpTransport;
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
httpTransport = new HttpTransportSE(URL, MSG_TIMEOUT);
httpTransport.debug = true;
httpTransport.call(SOAP_ACTION, envelope);//thread stops responding here
我什至尝试在预定义的超时后使用 Timer 取消该线程,但它不起作用。线程仍然存在,正在等待 2 分钟。
TimerTask task;
Timer mTimer;
task = new TimerTask() {
public void run() {
mThread.interrupt();
}
};
mTimer = new Timer();
mTimer.schedule(task, MSG_TIMEOUT);
我也收到了可能与它有关的警告(我不知道该怎么做):
Dx warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.ksoap2.transport.KeepAliveHttpsTransportSE$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
是否有机会使 KSOAP 工作或改进计时器以在预定义的超时后中断该线程?感谢您的回答或任何想法尝试什么!