简体   繁体   English

例外; 连接完成后无法设置请求属性; 发生在Android棒棒糖HTC M8上

[英]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. 您可以做两件事来确切地确定这是否是问题。

  1. Try renaming the ksoap2 class name 尝试重命名ksoap2类名
  2. Directly access ksoap2 class with preceding the package name. 直接访问package名称前面的ksoap2类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 给出java.lang.IllegalStateException的setRequestProperty方法:在建立连接后无法设置方法 - setRequestProperty method giving java.lang.IllegalStateException: Cannot set method after connection is made java.lang.IllegalStateException:设置连接后无法访问请求头字段 - java.lang.IllegalStateException: Cannot access request header fields after connection is set 在android棒棒糖或更高版本时设置windowTranslucentStatus = true - Set windowTranslucentStatus=true when android lollipop or higher 在设备上更新棒棒糖后,Android GCM无法正常工作 - Android GCM not working after Lollipop update on device 无法在我的HTC Evo上测试构建Android应用程序 - Cannot test build Android application on my HTC Evo 发生超时异常时如何设置重复 - How to set repetition when timeout exception occurs 无法建立WebSocket连接-Spark Java Framework - WebSocket connection cannot be made - Spark Java Framework 无法使用derby Client jdbc驱动程序建立连接 - connection cannot be made with derby client jdbc driver Android:例外:连接超时 - Android: Exception: Connection timeout 尝试在finally子句中关闭连接时发生SQL异常 - SQL exception occurs when trying to close the connection in finally clause
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM