关于android使用ksoap2报Caused by: java.lang.ClassCastException: org.ksoap2.SoapFault cannot be cast to org.ksoap2.serialization.SoapObject

Caused by: java.lang.ClassCastException: org.ksoap2.SoapFault cannot be cast to org.ksoap2.serialization.SoapObject

报这种类似的错误的,困扰了我挺久。偶尔报不是一直报。

原来是少了一个判断,因为服务器每次返回的不一定是我们想要的结果。

见图

困惑了好久,最后在 stackoverflow 里面才找到答案。

大概就是服务器异常的时候会导致这个,难怪我程序会崩溃有些时候,比如某个地方本该传一个 int 类型的,结果客户端这边没检测严格,然后直接传到接口去了,这个时候服务器那边如果没做检测,比如直接 int.parse("字符串"),出错或者极端点的,把接口的数据库帐号密码故意弄掉就会触发这个异常了。

尼玛头疼了许久这个问题

顺带一个,ksoap2,可以设置超时,看到很多别人的代码都不设置超时,一旦服务器给出结果比较久的话,也会异常掉。所以还是设置一个超时时间吧。受不了程序用着用着就崩溃掉。。。

时间: 2024-09-29 10:35:23

关于android使用ksoap2报Caused by: java.lang.ClassCastException: org.ksoap2.SoapFault cannot be cast to org.ksoap2.serialization.SoapObject的相关文章

Caused by: java.lang.ClassCastException: org.springframework.web.SpringServletContainerInitializer cannot be cast to javax.servlet.ServletContainerInitializer错误解决办法

严重: Failed to initialize end point associated with ProtocolHandler ["http-bio-8080"] java.net.BindException: Address already in use <null>:8080 at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:407) at org.apache.tomcat.util.

spring 切面织入报错:java.lang.ClassCastException: com.sun.proxy.$Proxy7 cannot be cast to...

报这个错,只有一个原因,就是转化的类型不对. 接口过父类的子类,在强制转换的时候,一定要用接口父类来定义. 代码示例: package com.luoluo.dao.impl; import java.sql.Connection; import java.sql.SQLException; import javax.annotation.Resource; import javax.sql.DataSource; import com.luoluo.dao.UserDAO; import co

spark提示Caused by: java.lang.ClassCastException: scala.collection.mutable.WrappedArray$ofRef cannot be cast to [Lscala.collection.immutable.Map;

spark提示Caused by: java.lang.ClassCastException: scala.collection.mutable.WrappedArray$ofRef cannot be cast to [Lscala.collection.immutable.Map; 起因 编写了一个处理两列是否相等的UDF,这两列的数据结构是一样的,但是结构比较复杂,如下: |-- list: array (nullable = true) | |-- element: map (conta

Caused by: java.lang.ClassCastException: org.springframework.web.SpringServletContainerInitializer cannot be cast to javax.servlet.ServletContainerInitializer

A child container failed during startjava.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/book_shop]] at java.util.concurrent.Futur

spring-cloud-alibaba-sentinel和feign配合使用,启动报Caused by: java.lang.AbstractMethodError: com.alibaba.cloud.sentinel.feign.SentinelContractHolder.parseAndValidateMetadata(Ljava/lang/Class;)Ljava/util/List

背景 我在学习spring-cloud-alibaba技术栈期间,在学习服务熔断与限流的时候,服务启动发生了以下异常 #这是控制台最上面的 sun.misc.Unsafe.park(Native Method) java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215) java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awa

idea连接spark集群报错解析:Caused by: java.lang.ClassCastException

cannot assign instance of scala.collection.immutable.List$SerializationProxy to field org.apache.spark.sql.execution.aggregate.SortAggregateExec.aggregateExpressions of type scala.collection.Seq in instance of org.apache.spark.sql.execution.aggregate

Eclipse报Caused by: java.lang.OutOfMemoryError: PermGen space解决思路

一.修改tomcat/bin目录下的catalina.bat 在“rem ----- Execute The Requested Command ----------------------”下加入 JAVA_OPTS="-server -Xms800m -Xmx800m -XXNewSize=256M -XX:PermSize=256M -XX:MaxNewSize=512m -XX:MaxPermSize=512m" . 这种方法在只使用tomcat时管用,但使用eclipse时不

Caused by: java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.HEADSET_PLUG

crash information:Caused by: java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.HEADSET_PLUG from    at android.os.Parcel.readException(Parcel.java:1465)     at android.os.Parcel.readException(Parcel.j

安卓出现错误: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.EditText

Caused by: Java.lang.ClassCastException: Android.widget.TextView cannot be cast to android.widget.EditText 该种报错信息,检查代码确定无误后,若还是出现这种错误,则可通过以下这个办法进行解决: 点中该项目-->点击Project-->clean   清理下再重新运行该项目,然后就解决了