I have used the above library for SOAP objects in my Android project, in order to connect to a .NET web service. The application was working fine till I made some changes and also increased/decreased target API. It started throwing SocketTimeoutException and wont go away.
I am using Android Developer Tools Build: v21.0.0-519525
Any help is appreciated.
private static final String NAMESPACE = "https://monitor.co.uk/";
private static final String URL = "https://monitor.co.uk/WebService.asmx";
private static final String GET_ID_METHOD = "GetId";
private static final String GET_ID_SOAP_ACTION = "https://monitor.co.uk/GetId";
public static String callGetIdWebService(String pass, String id, Context context)
{
String sRes = "";
try
{
SoapObject request = new SoapObject(NAMESPACE, GET_ID_METHOD);
PropertyInfo pi = new PropertyInfo();
pi.setName("pass");
pi.setValue(pass.toString());//"pass");//
pi.setType(pass.getClass());
request.addProperty(pi);
PropertyInfo pi2 = new PropertyInfo();
pi2.setName("id");
pi2.setValue(id.toString());
pi2.setType(id.getClass());
request.addProperty(pi2);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
envelope.implicitTypes = true;
HttpTransportSE httpTransport = new HttpTransportSE(URL);
httpTransport.debug = true;
httpTransport.call(GET_ID_SOAP_ACTION, envelope);
Object response = envelope.getResponse();
httpTransport.debug = true;
if(response.toString().equals("-1"))
{
sRes = "No records";
}
else
{
sRes = response.toString();
}
}
catch (Exception e)
{
e.printStackTrace();
Log.i("EXCEPTION...", e.toString());
}
return sRes;
}
Log Cat below:
01-28 17:39:34.213: W/System.err(16378): java.net.SocketTimeoutException
01-28 17:39:34.218: W/System.err(16378): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:130)
01-28 17:39:34.218: W/System.err(16378): at com.example.notificationmanager.CreateNotificationActivity.callGetIdWebService(CreateNotificationActivity.java:94)
01-28 17:39:34.218: W/System.err(16378): at com.example.notificationmanager.CreateNotificationActivity.createNotification(CreateNotificationActivity.java:37)
01-28 17:39:34.218: W/System.err(16378): at java.lang.reflect.Method.invokeNative(Native Method)
01-28 17:39:34.218: W/System.err(16378): at java.lang.reflect.Method.invoke(Method.java:511)
01-28 17:39:34.218: W/System.err(16378): at android.view.View$1.onClick(View.java:3095)
01-28 17:39:34.218: W/System.err(16378): at android.view.View.performClick(View.java:3627)
01-28 17:39:34.223: W/System.err(16378): at android.view.View$PerformClick.run(View.java:14329)
01-28 17:39:34.223: W/System.err(16378): at android.os.Handler.handleCallback(Handler.java:605)
01-28 17:39:34.223: W/System.err(16378): at android.os.Handler.dispatchMessage(Handler.java:92)
01-28 17:39:34.223: W/System.err(16378): at android.os.Looper.loop(Looper.java:137)
01-28 17:39:34.223: W/System.err(16378): at android.app.ActivityThread.main(ActivityThread.java:4511)
01-28 17:39:34.223: W/System.err(16378): at java.lang.reflect.Method.invokeNative(Native Method)
01-28 17:39:34.228: W/System.err(16378): at java.lang.reflect.Method.invoke(Method.java:511)
01-28 17:39:34.228: W/System.err(16378): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
01-28 17:39:34.228: W/System.err(16378): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
01-28 17:39:34.228: W/System.err(16378): at dalvik.system.NativeStart.main(Native Method)
Liaqat
Got this fixed after I had another couple of Exceptions going on with the app and some other kind folk on my other question replied and suggested to use AsyncTask. Once got the AsyncTask working, this error also went away. So, guess this is fine to assume the issue was caused by the same problem with doing network operation on GUI activity.
Many thanks for your assistance. Liaqat.
interesting, while increasing/decreasing target APIs and playing around with manifest, please make sure you have the internet permission: