Ksoap 库和请求超时?

发布于 2024-10-02 16:14:43 字数 616 浏览 0 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

逆蝶 2024-10-09 16:14:43

您必须修改 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文