I've been using the ksoap2-android library in a lot of my projects to use SOAP webservices. Why? Because I don't know any alternatives (maybe there aren't any).
My problem? Their reliability on a GPRS/EDGE network (no 3G/4G where I live).
Here is the code I usually use:
public String Login()
{
String status = "";
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,
SOAP_LOGIN_METHOD);
request.addProperty("strUserName", Login.uName);
request.addProperty("strPassword", Login.pass);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
Log.d("Login Request: ", "" + request.toString());
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
try
{
httpTransport.call(SOAP_LOGIN_ACTION, envelope);
SoapObject response = (SoapObject) envelope.bodyIn;
status = response.getProperty("LoginResult").toString();
Log.d("Login Status: ", ""
+ response.getProperty("LoginResult").toString());
}
catch (Exception exception)
{
Log.d("Login Service Exception", exception.toString());
status = "-1";
}
return status;
}
Now on a wifi network, this works mostly fine, but whenever I try the same via GPRS/EDGE, most of the service calls return a TIMEOUT or CONNECTION error.
I know the problem lies partly with the network as well, but at times for instance a Viber call is working fine (with a little packet drop here and there) but a webservice fails.
My question? Is there any way to increase the reliability of SOAP services on Android over a GPRS network?
I looked at the kSOAP2-android documentation to see if there was anything that might help, for instance, if the HTTP request fails once, and returns something we can use, we can but it in a loop to keep trying till it succeeds, but the return types are mostly void.