【发布时间】: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