Я использую ksoap2 2.5.4 (на Android 2.2), который поддерживает тайм-аут. Я использую Apache 2.2.16 для обработки своих запросов. Все работает нормально, но когда я выключаю свой Apache (или отключаю удаленный компьютер, на котором работает Apache), вызов никогда не прерывается. Я использую отдельный поток для вызова моего 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
Я даже пытался использовать таймер для отмены этого потока после заданного времени ожидания, но это не сработало. Тема еще там и ждет 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 работать или улучшить таймер для прерывания этого потока после заданного времени ожидания?
Спасибо за ответ или любую идею, что попробовать!