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