关于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,可以设置超时,看到很多别人的代码都不设置超时,一旦服务器给出结果比较久的话,也会异常掉。所以还是设置一个超时时间吧。受不了程序用着用着就崩溃掉。。。
关于android使用ksoap2报Caused by: java.lang.ClassCastException: org.ksoap2.SoapFault cannot be cast to org.ksoap2.serialization.SoapObject的更多相关文章
- Intellij Idea 12 开发Android 报Caused by: java.lang.UnsatisfiedLinkError: FindLibrary return null;
这次开发是用的百度地图api,导入两个so文件,结果启动的时候总是报Caused by: java.lang.UnsatisfiedLinkError: findlibrary return null ...
- 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. ...
- 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.Li ...
- 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 b ...
- SpringBoot整合Dubbo报错: java.lang.ClassCastException
com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote proxy method queryGoodsLimitPage to regi ...
- 报错:java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.xxx.entity.PersonEntity
报错:java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.xxx.entity.PersonEntity 代 ...
- Caused by: java.lang.ClassCastException: class java.lang.Double cannot be cast to class org.apache.hadoop.io.WritableComparable
错误: Caused by: java.lang.ClassCastException: class java.lang.Double cannot be cast to class org.apac ...
- java.lang.ClassCastException: oracle.sql.CLOB cannot be cast to oracle.sql.CLOB
错误现象: [framework] 2016-05-26 11:34:53,590 -INFO [http-bio-8080-exec-7] -1231863 -com.dhcc.base.db.D ...
- 【我的Android进阶之旅】Android 7.0报异常:java.lang.SecurityException: COLUMN_LOCAL_FILENAME is deprecated;
之前开发的一个和第三方合作的apk,在之前公司的 Android 5.1 系统的手表上运行正常,今天在公司新开发的 Android 7.1系统的手表上运行的时候,使用 DownloadManager ...
随机推荐
- Oracle 数据库二 基本查询
查询当前用户:show user 查看当前用户下的表:select *from tab; 设置行宽: show linesize;(查看行宽) set linesize 120;(设置行宽) ...
- Showing progress bar in a status bar pane
在工具卡显示进度条,原文链接:http://www.codeproject.com/Articles/35/Showing-progress-bar-in-a-status-bar-pane 1.构造 ...
- java工程中的相关路径
一.路径 绝对路径: 指的是文件在系统中的真实路径(物理路径). 相对路径: 指的是文件相对某个目录的相对路径. 对于java application 工程来说,当编写完一个类之后,class文件会编 ...
- jQuery Validate 表单验证插件----在class属性中添加校验规则进行简单的校验
一.下载插件包. 网盘下载:https://yunpan.cn/cryvgGGAQ3DSW 访问密码 f224 二.jQuery表单验证插件----添加class属性形式的校验 <!DOCTY ...
- 将HTML特殊转义为实体字符的两种实现方式
前端开发工作中,经常需要将HTML的左右尖括号等转义成实体形式.我们不能把<,>,&等直接显示在最终看到的网页里.需要将其转义后才能在网页上显示. 转义字符(Escape Sequ ...
- [转]Android输出Log到文件
前言:开发中遇到mx4这款机型Eclipse联调不上,logcat看不了,需要输出生成文件查看调试信息.网上搜了下,功能很完善了.startService和过滤输出信息需要自己添加设置,另外注意添加权 ...
- Hive query issue
One time, I have written a query with two tables join, One table is big table with partitions , anot ...
- Mongodb 主从复制与副本集实验
1.实验主从复制,并验证复制成功,抓图实验过程 Step1:创建相应的目录 Mkdir -p ./dbs/master Mkdir -p ./dbs/slave Step2:开启主服务 ./bin/ ...
- SDRAM总结
使用的流程 W9825G6JH winbond sdram 4M words X 4banks X 16bits=. Accesses to the SDRAM are burst oriented. ...
- 用于json的 .ashx 小细节
public void ProcessRequest(HttpContext context) { switch (action) { case "attribute_field_valid ...