Android使用ksoap2连接wcf webservice有时无法连接到服务器

Android使用ksoap2连接wcf webservice有时无法连接到服务器,android,web-services,wcf-data-services,android-ksoap2,Android,Web Services,Wcf Data Services,Android Ksoap2,我有一个问题,当我使用ksoap2连接wcfwebservice时,有时我可以成功连接并获取数据,但有时失败(socketexception:fail to connect to server)互联网在所有情况下都是正常的 我已经为每个连接设置了10000毫秒的超时 HttpTransportSE androidHttpTransport = new HttpTransportSE(URL,10000); 你必须优雅地处理这些错误。记住,移动设备上的互联网可能不稳定。这取决于信号 例如,手机可

我有一个问题,当我使用ksoap2连接wcfwebservice时,有时我可以成功连接并获取数据,但有时失败(socketexception:fail to connect to server)互联网在所有情况下都是正常的

我已经为每个连接设置了10000毫秒的超时

HttpTransportSE androidHttpTransport = new HttpTransportSE(URL,10000);

你必须优雅地处理这些错误。记住,移动设备上的互联网可能不稳定。这取决于信号

例如,手机可能正在从GPRS信号转换为3G信号。这意味着它可以有效地重新启动internet连接

我会这样做:

 try
 {
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL,10000);
 }
 except(Exception e)
 {
    //Do something with the exception
    // You can try to reconnect.
    // You can report the error to the user.
    // You can do some network diagnostics here.
    // The thing is that networks on mobiles are unreliable so handle the exception.
 }