例外;建立连接后无法设置请求属性;发生在Android棒棒糖HTC M8上 [英] Exception; Cannot set request property after connection is made; occurs on Android lollipop HTC M8

查看:89
本文介绍了例外;建立连接后无法设置请求属性;发生在Android棒棒糖HTC M8上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Soap请求从Android应用程序调用Java Web Service.有一种可以通过应用程序调用的方法,该方法在几乎所有设备以及三星Lollipop设备中的Android版本至Kit Kat版本中都可以正常使用,但不适用于HTC M8 Lollipop更新的设备.
以下是我的代码.

I am calling a Java Web Service from an Androidapplication using Soaprequests. 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();
}

当尝试获得注释所指示的响应时,会出现Exception,确切的Exception如下所示.

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)

我一直在搜索,但是甚至找不到正确的答案或解决方法.

我在找
Ksoap2 Android IllegalStateException

提供java.lang.IllegalStateException的setRequestProperty方法:连接后无法设置方法制成

我不知道为什么它会在HTC M8 Lollipop设备中发生,而在三星Lollipop设备中却没有.
任何建议或解决方法,不胜感激.
谢谢

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

推荐答案

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

I think this might explain the issue. Look for the 4th particle in the thread.
https://code.google.com/p/ksoap2-android/issues/detail?id=205&can=1&start=200
It says,

啊..他们可能已在其固件中添加了ksoap2 android. 会解释的.不确定除阴影外您还能做些什么 您使用的整个ksoap2-android软件包以及所有依赖项 您自己的名称空间.一个相当大的事业.

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..

您可以做两个可能的事情来确切地确定这是否是问题所在.

You can do two possible things to identify exactly if this is the issue.

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

这篇关于例外;建立连接后无法设置请求属性;发生在Android棒棒糖HTC M8上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆