Search code examples
androidproxysocketexceptionksoapenvelope

ksoap timeout behind proxy in android


i tried the example from http://www.helloandroid.com/tutorials/using-ksoap2-android-and-parsing-output-data to get request and response from a wsdl service. its working fine when i tried in a proxyless. but when i work behind proxy,i get "The operation timed out:request time failed: java.net.SocketException" is there any way to set proxy to SoapObject or Soap Envelop?


Solution

  • Ksoap does not work behind a proxy. inorder to make that working.. download the HttpTransportSE.java and ServiceConnectionSE.java from sourceforge.

    Create a package with HttpTransportSE and ServiceConnectionSE.

    In ServiceConnectionSE constructor:

     String myProxy=android.net.Proxy.getDefaultHost() ;
                int myPort=android.net.Proxy.getDefaultPort();
    
                if(myProxy!=null){
                    Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(myProxy, myPort));
                    connection = (HttpURLConnection) new URL(url).openConnection(proxy);
                }
                else
                {
                    connection = (HttpURLConnection) new URL(url).openConnection();
                }
    

    now wherever we call HttpTransportSE.call()method make sure that it points to ur own package which has this two files.