简体   繁体   English

Android代理后面的ksoap超时

[英]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. 我尝试了来自http://www.helloandroid.com/tutorials/using-ksoap2-android-and-parsing-output-data的示例,以从wsdl服务获取请求和响应。 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? 但是当我在代理后面工作时,出现“操作超时:请求时间失败:java.net.SocketException” ,有没有办法将代理设置为SoapObject或Soap Envelop?

Ksoap does not work behind a proxy. Ksoap无法在代理后面工作。 inorder to make that working.. download the HttpTransportSE.java and ServiceConnectionSE.java from sourceforge. 为了使它正常工作。从sourceforge下载HttpTransportSE.java和ServiceConnectionSE.java。

Create a package with HttpTransportSE and ServiceConnectionSE. 使用HttpTransportSE和ServiceConnectionSE创建一个包。

In ServiceConnectionSE constructor: 在ServiceConnectionSE构造函数中:

 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. 现在无论我们在哪里调用HttpTransportSE.call()方法,都要确保它指向您的拥有这两个文件的软件包。

Hi Everyone , The latest version of KSOAP2.6.5 [Tested it and verified it] has fix for the proxy authentication issue . 大家好,KSOAP2.6.5的最新版本[经过测试并验证]已解决了代理身份验证问题。 The HTTPTransportSE constructor now accepts java.net.Proxy instance as a parameter along with URL. 现在, HTTPTransportSE构造函数将java.net.Proxy实例与URL一起接受为参数。 The method will be like 方法会像
HttpTransportSE httpTransport=new HttpTransportSE(proxy,URL);
If your proxy is configured and if it requires authentication then use Authenticator class to setup your proxy credentials and have success. 如果您的代理已配置,并且需要身份验证,则使用Authenticator类来设置您的代理凭据并获得成功。 HTH , if not write me back HTH,如果不给我回信

据我所知,您必须自己在android操作系统设置中设置代理,它将正常工作。

Replace with this.. 替换为此。

//Timeout in milliseconds

int timeout=60000;
AndroidHttpTransport androidHttpTransport=new AndroidHttpTransport(url, timeout);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM