在 Android 中从 Web 服务获取响应时出现 SocketTimeOutExcpetion

SocketTimeOutExcpetion while getting response from web services in Android

我想从 dot net web 获得响应-services.I 我在我的应用程序中使用 web_service,但是当我到达 HttpTransportse 时显示 SocketTimeoutException 并且没有得到回应。

这是错误 line.And 在第 androidHttpTransport.call(SOAP_ACTION+webMethName, envelope); 行收到错误我在过去 1 天尝试过但没有解决问题。

感谢任何帮助。如何解决这个问题。

我这边有什么问题吗

错误:

5-10 11:18:38.245: W/System.err(849): java.net.SocketTimeoutException
05-10 11:18:38.255: W/System.err(849):  at org.ksoap2.transport.HttpTransportSE.call(Http

代码:

public static String invokeHelloWorldWS(String name, String webMethName) {
        String resTxt = null;

        SoapObject request = new SoapObject(NAMESPACE, webMethName);

        PropertyInfo sayHelloPI = new PropertyInfo();

        sayHelloPI.setName("Name");

        sayHelloPI.setValue(name);

        sayHelloPI.setType(String.class);

        request.addProperty(sayHelloPI);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);

        envelope.dotNet = true;

        envelope.setOutputSoapObject(request);

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

        try {

            androidHttpTransport.call(SOAP_ACTION+webMethName, envelope);

            SoapPrimitive response = (SoapPrimitive) envelope.getResponse();

            resTxt = response.toString();

        } catch (Exception e) {

            e.printStackTrace();

            resTxt = "Error occured";
        } 

        return resTxt;
    }
}

尝试改变

 HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 

通过

HttpTransportSE androidHttpTransport = new HttpTransportSE(URL,80000);

并检查您的 manifest.xml 文件,您是否已授予互联网许可?

 <uses-permission android:name="android.permission.INTERNET" />
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />