I have developed software that uses the ksoap library and communicates with a .NET web service.
all works fine and fast in the android 2.2 version.
Recently, I was forced to move to the 2.3.3 Android version.
i just changed in the project properties to 2.3.3 and compile.
there is some bugs but the one who Worries me the most is that the communication with the web service is really really slow...
I'm using ksoap 2.5.7 version...
and idea??
thanks in advance!
My Make Request function:
public void MakeRequest(final String MethodName,
final PropertyInfo[] props, final ResponseListener resListener,
final int timeout, final int retries)
{
GeneralMethods.debug(this.getClass().toString(), "MakeRequest",
"MethodName=" + MethodName);
for (PropertyInfo prop : props)
{
if (prop != null && prop.getValue() != null)
GeneralMethods.debug(this.getClass().toString(), "MakeRequest",
prop.name + "=" + prop.getValue().toString());
}
final Handler uiThreadCallback = new Handler();
final Thread RequestThread = new Thread()
{
public void run()
{
try
{
SoapObject Request = new SoapObject(NAMESPACE, MethodName);
// adding properties
if (props != null)
for (PropertyInfo pi : props)
{
if (pi.getValue() != null
&& isComplexType(pi.getValue().getClass()
.getName()))
{
PropertyInfo complexProp = new PropertyInfo();
complexProp
.setValue(getSoapClass(pi.getValue()));
complexProp.setName(pi.getName());
Request.addProperty(complexProp);
}
else
Request.addProperty(pi);
}
// Set the web service envelope
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(Request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(
URL, timeout);
androidHttpTransport.debug = true; // TODO: comment it on
// finish debug
// Load cookies
List<HeaderProperty> httpHeaders = new ArrayList<HeaderProperty>();
for (String cookie : cookies.keySet())
{
httpHeaders.add(new HeaderProperty("Cookie", cookie
+ "=" + cookies.get(cookie)));
}
// Call the web service and retrieve result
@SuppressWarnings("rawtypes")
List reshttpHeaders = androidHttpTransport.call(NAMESPACE
+ MethodName, envelope, httpHeaders);
// save cookies
Log.d("DEBUG OUTGOING XML",
androidHttpTransport.requestDump);
androidHttpTransport.debug = true;
Log.d("DEBUG INCOMING XML=========================================",
androidHttpTransport.responseDump);
if (reshttpHeaders != null)
{
for (int i = 0; i < reshttpHeaders.size(); i++)
{
HeaderProperty hp = (HeaderProperty) reshttpHeaders
.get(i);
String key = hp.getKey();
String value = hp.getValue();
if (key != null && value != null)
{
if (key.equalsIgnoreCase("set-cookie"))
{
String cookieString = value.substring(0,
value.indexOf(";"));
cookies.put(cookieString.substring(0,
cookieString.indexOf("=")),
cookieString.substring(cookieString
.indexOf("=") + 1));
break;
}
}
}
}
// Log.i("test", httpHeaders.toString());
// final Object res = envelope.getResponse();
final Object res = envelope.getResponse();
uiThreadCallback.post(new Runnable()
{
public void run()
{
// Log.i("Talk2Doc", res.toString());
GeneralMethods.debug(this.getClass().toString(),
"MakeRequest", "Responce -> MethodName="
+ MethodName);
resListener.onGotResponse(res);
}
});
}
catch (final Exception e)
{
GeneralMethods.debug(this.getClass().toString(),
"MakeRequest", "Error -> MethodName=" + MethodName
+ ", Error=" + e.getMessage());
uiThreadCallback.post(new Runnable()
{
public void run()
{
e.printStackTrace();
if (e.getMessage().contains("login failed"))
resListener.onLoginError();
else
{
if (retries < 1
|| e.getClass() == SocketTimeoutException.class)
resListener.onResponseError(e);
else
{
// retry
MakeRequest(MethodName, props, resListener,
timeout, retries - 1);
}
}
}
});
}
}
};
RequestThread.start();
}