java.lang.classcastexception org.ksoap2.soapfault cannot be cast to org.ksoap2.serialization.soapobj
2015-11-02 18:06
417 查看
when you are dealing with SOAP Web Service, This problem may come some time. The response coming from the service can either be a SOAP Object and if something goes wrong like wrong credentials passed then Response comes with error message and it's a SOAPFAULT
Object. So update your code of parsing to check the type of the response object.
This sort of code can solve your problem,
if (envelope.bodyIn instanceof SoapFault) {
String str= ((SoapFault) envelope.bodyIn).faultstring;
Log.i("", str);
// Another way to travers through the SoapFault object
/* Node detailsString =str= ((SoapFault) envelope.bodyIn).detail;
Element detailElem = (Element) details.getElement(0)
.getChild(0);
Element e = (Element) detailElem.getChild(2);faultstring;
Log.i("", e.getName() + " " + e.getText(0)str); */
} else {
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
Log.d("WS", String.valueOf(resultsRequestSOAP));
}
Can't find bundle for base name ClientMessages, locale zh_CN
这是个关于JAVA国际化方面的语音包的问题。
提示这个错误信息就是说找不到代码里写的配置文件。
我这个错误发生在导入一个已经存在的项目时发生的。
解决办法:将配置文件*.properties所在的文件夹加入到项目的build path中。
比如我这个项目是将所有的*.properties文件放在config文件夹下的。
那么右击项目属性->Java Build Path->Source->Add Folder加入config文件夹即可。
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
引申阅读:
实际上系统在寻找配置文件时,是从source目录里面开始寻找的。
所以我们的目的就是把这些配置文件放到source目录里面就行了。
因此,我们除了上面的方法外也可以直接将*.properties文件直接放到src目录下,也能解决问题。
Object. So update your code of parsing to check the type of the response object.
This sort of code can solve your problem,
if (envelope.bodyIn instanceof SoapFault) {
String str= ((SoapFault) envelope.bodyIn).faultstring;
Log.i("", str);
// Another way to travers through the SoapFault object
/* Node detailsString =str= ((SoapFault) envelope.bodyIn).detail;
Element detailElem = (Element) details.getElement(0)
.getChild(0);
Element e = (Element) detailElem.getChild(2);faultstring;
Log.i("", e.getName() + " " + e.getText(0)str); */
} else {
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
Log.d("WS", String.valueOf(resultsRequestSOAP));
}
Can't find bundle for base name ClientMessages, locale zh_CN
这是个关于JAVA国际化方面的语音包的问题。
提示这个错误信息就是说找不到代码里写的配置文件。
我这个错误发生在导入一个已经存在的项目时发生的。
解决办法:将配置文件*.properties所在的文件夹加入到项目的build path中。
比如我这个项目是将所有的*.properties文件放在config文件夹下的。
那么右击项目属性->Java Build Path->Source->Add Folder加入config文件夹即可。
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
引申阅读:
实际上系统在寻找配置文件时,是从source目录里面开始寻找的。
所以我们的目的就是把这些配置文件放到source目录里面就行了。
因此,我们除了上面的方法外也可以直接将*.properties文件直接放到src目录下,也能解决问题。
相关文章推荐
- Ubuntu 12.04 安装JDK 8和Eclipse
- 关于UtilTimerStack类的使用--XWork2、Struts2内置性能诊断类
- 20140923-瞬时模型化Eclipse SWT应用界面
- 20140923-瞬时模型化Java Swing应用界面
- 打开新的eclipse 及 eclipse 中 svn代理设置
- java基础之 “==”和“ equals”以及instanceof的区别
- java目录结构配置,便于自己调整svn新下代码
- JAVA中HashMap和HashTable的区别
- java(基础)学习第一步:安装jdk,配置环境变量
- springMVC+MyBatis搭建心得
- 解决Eclipse 导入工程包 总是出现红叉的问题
- JavaBeans
- Java 导出CSV文件及实现web下载CSV
- JUNIT的粗略介绍
- javabean转换成xml(XStream)小工具
- java:转换时间格式为String
- Java字符串技巧之删除标点或最后字符的方法
- 获取一段时间的起止时间
- JAVA 类与对象
- Java语言基础之包与权限修饰符