【问题标题】:Exception; Cannot set request property after connection is made; occurs on Android lollipop HTC M8例外;建立连接后无法设置请求属性;发生在 Android 棒棒糖 HTC M8
【发布时间】:2015-04-21 07:05:25
【问题描述】:

我正在使用Soaprequests 从Androidapplication 调用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 设备中。
非常感谢任何建议或解决方法。
谢谢

【问题讨论】:

    标签: java android web-services android-5.0-lollipop android-ksoap2


    【解决方案1】:

    我认为这可以解释这个问题。在线程中寻找第 4th 粒子。
    https://code.google.com/p/ksoap2-android/issues/detail?id=205&can=1&start=200
    它说,

    啊..他们可能在固件中添加了 ksoap2 android.. 会解释的。不确定除了着色之外你还能做什么 您使用的整个 ksoap2-android 包和任何依赖项 你自己的命名空间。一项相当艰巨的任务..

    您可以做两种可能的事情来确定这是否是问题所在。

    1. 尝试重命名ksoap2类名
    2. 直接访问ksoap2 类,前面带有package 名称。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-19
      • 1970-01-01
      • 1970-01-01
      • 2019-11-18
      • 2015-05-07
      • 2016-02-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多