I'm trying to invoke a public web service via KSOAP(2.5.8). But it is not able to get data from service in ice-cream sandwich versions. It work's fine in lower versions like 2.2 and 2.3. Here's my code.
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.util.Log;
public class WebService {
private final String NAMESPACE ="http://aaaaaa.org/";
private final String URL ="http://5xxxxxxxxxxx.asmx?WSDL";
public boolean checkUser(String _EmailID, String _Password) {
boolean result = false;
final String SOAP_ACTION ="http://aaaaaaaa/Login";
final String METHOD_NAME = "Login";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo propertyInfoEmail = new PropertyInfo();
propertyInfoEmail.setName("_EmailID");
propertyInfoEmail.setValue(_EmailID);
propertyInfoEmail.setType(String.class);
request.addProperty(propertyInfoEmail);
PropertyInfo propertyInfoPassword = new PropertyInfo();
propertyInfoPassword.setName("_Password");
propertyInfoPassword.setValue(_Password);
propertyInfoPassword.setType(String.class);
request.addProperty(propertyInfoPassword);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true; // put this only if the web service is .NET one
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
Log.i("myApp", response.toString());
if(response.toString().equalsIgnoreCase("true")){
result = true;
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
Every time it returns false result in ice-cream sandwich . It doesn't show anything in error log. What should i change here. plz help me.
The problem is that ICS will not let you to do some networking stuff on activity. That means that you have to place your call to web service in a background task (AsyncTask). In this link you can see what to do: here