android中代理背后的ksoap超时

发布于 2024-10-16 01:57:17 字数 355 浏览 2 评论 0原文

我尝试了 http://www.helloandroid 中的示例。 com/tutorials/using-ksoap2-android-and-parsing-output-data 从 wsdl 服务获取请求和响应。当我尝试无代理时它工作正常。但是当我在代理后面工作时,我得到“操作超时:请求时间失败:java.net.SocketException”有什么方法可以将代理设置为SoapObject或Soap信封?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

意犹 2024-10-23 01:57:17

Ksoap 不能在代理后面工作。为了使其发挥作用..
从 sourceforge 下载 HttpTransportSE.java 和 ServiceConnectionSE.java。

使用 HttpTransportSE 和 ServiceConnectionSE 创建包。

在 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();
            }

现在无论我们在哪里调用 HttpTransportSE.call() 方法,请确保它指向您自己的包含这两个文件的包。

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.

你又不是我 2024-10-23 01:57:17

  大家好,最新版本的KSOAP2.6.5[测试并验证]已修复代理身份验证问题。 HTTPTransportSE 构造函数现在接受 java.net.Proxy 实例作为参数以及 URL。该方法将是这样的

         HttpTransportSE httpTransport=new HttpTransportSE(代理,URL);

  如果您的代理已配置并且需要身份验证,则使用
Authenticator 类来设置您的代理凭据并取得成功。 HTH,如果不给我回信

  Hi Everyone , The latest version of KSOAP2.6.5 [Tested it and verified it] has fix for the proxy authentication issue . The HTTPTransportSE constructor now accepts java.net.Proxy instance as a parameter along with 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. HTH , if not write me back

泪痕残 2024-10-23 01:57:17

据我所知,你必须在 Android 操作系统设置中设置代理,它就会正常工作。

As far as I know you have to set up the proxy in android operating system settings themselves and it will work fine.

枫林﹌晚霞¤ 2024-10-23 01:57:17

换成这个..

//Timeout in milliseconds

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

Replace with this..

//Timeout in milliseconds

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