您的位置:首页 > 编程语言 > Java开发

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目录下,也能解决问题。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: