java.lang.classcastexception org.ksoap2.soapfault cannot be cast to org.ksoap2.serialization.soapobj



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目录下,也能解决问题。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值