Android ksoap connection timed out when using more than one device on same wireless network :(

半城伤御伤魂 提交于 2019-12-11 08:10:25

问题


In short, my application works for longer than year now. I have 100000+ downloads, and only recently the problems with my soap web services started to occur. If two or more devices are connected to the same wireless connection only one device is working properly. On all the other devices connection gets timed out. Here is sample of WS call method:

public static Object callWSMethod(String methodName, String soapAction,
        PropertyInfo[] properties) throws IOException,
        XmlPullParserException{

    SoapObject request = new SoapObject(NAMESPACE, methodName);
    if (properties != null)
        for (PropertyInfo property : properties) {
            request.addProperty(property);
        }

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);
    envelope.implicitTypes = true;

    HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS, 15000);       
    httpTransport.debug = true;             
    httpTransport.call(soapAction, envelope);

    return envelope.getResponse();
}

Any suggestions or ideas would be helpful.


回答1:


Turns out ksoap2 works well, and my code works well. After tracing ksoap call method, and sniffing html traffic I found out that, sometimes, server doesn't respond on my requests. This happens because server configuration was changed and now, when there are a lot of requests from the same IP address, server treats some of them as retransmission and ignores them. This problem has to be solved on server side.




回答2:


I have set the timeout in milliseconds like below while calling webservice

HttpTransportSE androidHttpTransport = new HttpTransportSE(URL,6000);

(Note - make sure you are using latest ksoap2 library. if you want to download newest version of ksoap2 the follow below link to download)

https://oss.sonatype.org/content/repositories/ksoap2-android-releases//com/google/code/ksoap2-android/ksoap2-android-assembly/3.0.0-RC.4/

and click on ksoap2-android-assembly-3.0.0-RC.4.jar



来源:https://stackoverflow.com/questions/17478082/android-ksoap-connection-timed-out-when-using-more-than-one-device-on-same-wirel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!