后面的Andr​​oid代理KSOAP超时后面、Andr、KSOAP、oid

2023-09-05 05:16:34 作者:讨厌你这张装b的脸丶

我试图从的http://www.helloandroid.com/tutorials/using-ksoap2-android-and-parsing-output-data得到请求和响应从WSDL服务。它工作正常,当我试图在proxyless。但是当我的工作背后的代理,我得到的的操作超时:请求时失败:产生java.net.SocketException的有没有什么办法来设置代理SoapObject或肥皂信封?

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?

推荐答案

KSOAP不使用代理工作。序作出这样的工作.. 下载HttpTransportSE.java和ServiceConnectionSE.java从SourceForge。

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

与HttpTransportSE和ServiceConnectionSE创建一个包。

Create a package with HttpTransportSE and ServiceConnectionSE.

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

现在的地方,我们称之为HttpTransportSE.call()方法,确保它指向UR自己的包里面有这两个文件。

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