[英]Exception; Cannot set request property after connection is made; occurs on Android lollipop HTC M8
I am calling a Java Web Service
from an Android
application using Soap
requests. 我使用Soap
请求从Android
应用程序调用Java Web Service
。 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. 有一种方法可以通过应用程序调用,几乎在所有设备和三星Lollipop
设备中,在Android
版本中可以正常使用Kit Kat
,但在HTC M8 Lollipop更新设备上无效。
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. 一个Exception
试图得到响应时,由注释指示和确切发生Exception
如下。
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 Ksoap2 Android IllegalStateException
and 和
setRequestProperty method giving java.lang.IllegalStateException: Cannot set method after connection is made 给出java.lang.IllegalStateException的setRequestProperty方法:在建立连接后无法设置方法
I have no idea why it is occured in HTC M8 Lollipop
device but not in Samsung Lollipop
devices. 我不知道为什么它出现在HTC M8 Lollipop
设备中,而不是在三星Lollipop
设备中出现。
Any suggestions or workarounds are much appreciated. 任何建议或解决方法都非常感谢。
Thank you 谢谢
I think this might explain the issue. 我认为这可以解释这个问题。 Look for the 4 th particle in the thread. 寻找线程中的第 4 个粒子。
https://code.google.com/p/ksoap2-android/issues/detail?id=205&can=1&start=200 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. 啊......他们可能已经在他们的固件中添加了ksoap2 android ..这可以解释它。 Not sure that is anything you can do beyond shading the whole ksoap2-android package you use and any dependencies into your own namespace. 除了将你使用的整个ksoap2-android软件包和任何依赖项整理到你自己的命名空间之外,你不能确定这是什么。 A rather huge undertaking.. 一项相当庞大的事业......
You can do two possible things to identify exactly if this is the issue. 您可以做两件事来确切地确定这是否是问题。
ksoap2
class name 尝试重命名ksoap2
类名 ksoap2
class with preceding the package
name. 直接访问package
名称前面的ksoap2
类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.