I am calling a Java Web Service
from an Android
application using Soap
requests. There is a certain method to be called through the app which works fine in Android
versions up to Kit Kat
in almost all the devices and in Samsung Lollipop
devices too, but doesn't work on HTC M8 Lollipop updated device.
Following is my code.
HttpTransportSE ht = new HttpTransportSE("URL");
SoapObject so = new SoapObject("Namespace", "Method");
try {
SoapSerializationEnvelope se = new SoapSerializationEnvelope(SoapEnvelope.VER11);
so.addProperty("input1", data);
data = se.getResponse().toString();//This is where Exception occurs
}catch(Exception ex){
ex.printStackTrace();
}
An Exception
occurs when trying to get the response as indicated by the comment and the exact Exception
is as follows.
java.lang.IllegalStateException: Cannot set request property after connection is made
at com.android.okhttp.internal.http.HttpURLConnectionImpl.setRequestProperty(HttpURLConnectionImpl.java:496)
at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.setRequestProperty(DelegatingHttpsURLConnection.java:258)
at com.android.okhttp.internal.http.HttpsURLConnectionImpl.setRequestProperty(HttpsURLConnectionImpl.java:25)
at org.ksoap2.transport.ServiceConnectionSE.setRequestProperty(ServiceConnectionSE.java:101)
at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:156)
at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:116)
I have been searching for this but could not find a proper answer or a workaround even.
I looked for
Ksoap2 Android IllegalStateException
and
setRequestProperty method giving java.lang.IllegalStateException: Cannot set method after connection is made
I have no idea why it is occured in HTC M8 Lollipop
device but not in Samsung Lollipop
devices.
Any suggestions or workarounds are much appreciated.
Thank you
I think this might explain the issue. Look for the 4th particle in the thread.
https://code.google.com/p/ksoap2-android/issues/detail?id=205&can=1&start=200
It says,
Ahh.. they might have added ksoap2 android in their firmware.. that would explain it. Not sure that is anything you can do beyond shading the whole ksoap2-android package you use and any dependencies into your own namespace. A rather huge undertaking..
You can do two possible things to identify exactly if this is the issue.
ksoap2
class name ksoap2
class with preceding the package
name. If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With