我使用支持超時的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