Ksoap 库和请求超时?
我正在使用 ksoap 库来调用 android 中的 web 服务。 如果在通话过程中互联网不可用,我在这里看不到请求超时属性,因此拥有它很重要。
有人建议我使用具有 Sotimeout 的套接字类,但我不知道如何在这里实现它,有人建议我该怎么办?
public void callWebservice()
{
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("passonString", "anything");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
..
...
}catch(Exception ex)
{}
}
i am using ksoap library to call webservice in android.
i dont see request timeout property here in case of INTERNET is not available in the middle of call so it is important to have it.
some one suggested me to use socket class which has Sotimeout but i dont know how to implement it here any one suggest me what should i do?
public void callWebservice()
{
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("passonString", "anything");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
..
...
}catch(Exception ex)
{}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须修改 HttpTransportSE 类以获取传递到套接字的超时参数。实现起来非常简单,但是看看 HttpsTransportSE 类已经做到了这一点。
然后你可以捕获 SocketTimeoutException 并执行任何必要的操作。请随意在项目上创建问题或贡献增强功能。
You would have to modify the HttpTransportSE class to take a timeout parameter that passes through to the socket. It would be pretty simple to implement, but looking at the HttpsTransportSE class that already does this.
Then you could catch the SocketTimeoutException and do whatever necessary. Feel free to create an issue on the project and or contribute the enhancement.