例外;建立连接后无法设置请求 属性;发生在 Android 棒棒糖 HTC M8 上
Exception; Cannot set request property after connection is made; occurs on Android lollipop HTC M8
我正在使用 Soap
请求从 Android
应用程序调用 Java Web Service
。有一种方法可以通过应用程序调用,它在 Android
版本到 Kit Kat
几乎所有设备和三星 Lollipop
设备中都可以正常工作,但不适用于HTC M8 Lollipop 更新设备。
以下是我的代码。
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();
}
在尝试获取评论指示的响应时发生 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)
我一直在寻找这个,但甚至找不到合适的答案或解决方法。
我找了
Ksoap2 Android IllegalStateException
和
setRequestProperty method giving java.lang.IllegalStateException: Cannot set method after connection is made
我不知道为什么它会出现在 HTC M8 Lollipop
设备中,但不会出现在三星 Lollipop
设备中。
非常感谢任何建议或解决方法。
谢谢
我想这或许可以解释这个问题。在线程中寻找第 4th 个粒子。
https://code.google.com/p/ksoap2-android/issues/detail?id=205&can=1&start=200
它说,
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..
您可以做两件事来准确确定这是否是问题所在。
- 尝试重命名
ksoap2
class 名称
- 在
package
名称前直接访问 ksoap2
class。
我正在使用 Soap
请求从 Android
应用程序调用 Java Web Service
。有一种方法可以通过应用程序调用,它在 Android
版本到 Kit Kat
几乎所有设备和三星 Lollipop
设备中都可以正常工作,但不适用于HTC M8 Lollipop 更新设备。
以下是我的代码。
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();
}
在尝试获取评论指示的响应时发生 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)
我一直在寻找这个,但甚至找不到合适的答案或解决方法。
我找了
Ksoap2 Android IllegalStateException
和
setRequestProperty method giving java.lang.IllegalStateException: Cannot set method after connection is made
我不知道为什么它会出现在 HTC M8 Lollipop
设备中,但不会出现在三星 Lollipop
设备中。
非常感谢任何建议或解决方法。
谢谢
我想这或许可以解释这个问题。在线程中寻找第 4th 个粒子。
https://code.google.com/p/ksoap2-android/issues/detail?id=205&can=1&start=200
它说,
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..
您可以做两件事来准确确定这是否是问题所在。
- 尝试重命名
ksoap2
class 名称 - 在
package
名称前直接访问ksoap2
class。