War*_*ock 3 android timeout ksoap ksoap2 android-ksoap2
我正在使用支持超时的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
Run Code Online (Sandbox Code Playgroud)
我甚至尝试使用Timer在预定义的超时后取消该线程,但它不起作用.线程仍在那里等待2分钟.
TimerTask task;
Timer mTimer;
task = new TimerTask() {
public void run() {
mThread.interrupt();
}
};
mTimer = new Timer();
mTimer.schedule(task, MSG_TIMEOUT);
Run Code Online (Sandbox Code Playgroud)
我也得到这个可能与它有关的警告(我不知道该怎么办):
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.
Run Code Online (Sandbox Code Playgroud)
是否有机会使KSOAP工作或改进计时器以在预定义超时后中断该线程?感谢您的回答或任何想法尝试!
使用ksoap2 API 2.5.2或更高版本.
你可以点击这里下载
并在创建HTTPTransport对象时使用以下代码.
/**
* Creates instance of HttpTransportSE with set url
*
* @param url
* the destination to POST SOAP data
*/
public HttpTransportSE(String url) {
super(url);
}
/**
* Creates instance of HttpTransportSE with set url
*
* @param url
* the destination to POST SOAP data
* @param timeout
* timeout for connection and Read Timeouts (milliseconds)
*/
public HttpTransportSE(String url, int timeout) {
super(url, timeout);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12640 次 |
| 最近记录: |