我使用支持超时的ksoap2 2.5.4(在Android 2.2上)。我使用Apache 2.2.16来处理我的请求。一切工作正常,但是当我关闭我的Apache(或断开运行Apache的远程PC)时,调用永远不会超时。我使用单独的线程来调用我的WS,并且在这种情况下,此线程停止工作/响应/停顿约2分钟。KSOAP永不超时
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
我甚至试图用预定义的超时后取消该线程,但它没有工作。线程仍在那里,正在等待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工作或改进定时器以在预定义超时后中断该线程? 谢谢你的回答或任何想法试试!
另一个问题,你尝试没有httpTransport.debug = true; ? (试图找到错误) – 2011-04-15 08:32:25