Search code examples
javaandroidweb-servicesandroid-ksoap2

SocketTimeOutExcpetion while getting response from web services in Android


I want to get the response from dot net web-services.I am using a web_service in my application , but when i reached at HttpTransportse Shows SocketTimeoutException and not getting response.

Here is the error line.And getting the error at line androidHttpTransport.call(SOAP_ACTION+webMethName, envelope); I tried last 1 day but did not solve the issue.

Any help is appreciated. How to solve this issue.

Is any problem from my end

Error:

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

Code:

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;
    }
}

Solution

  • Try to change

     HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 
    

    Via

    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL,80000);
    

    and check your manifest.xml file, weather you have given the internet permission or not?

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