得到SoapObject布尔(kSOAP2) [英] Get boolean from SoapObject (kSOAP2)

查看:222
本文介绍了得到SoapObject布尔(kSOAP2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从一个SoapObject一个布尔值,我已经从Android中使用kSOAP2 Web服务器...的响应变得

I'm trying to get a boolean value from a SoapObject, I've gotten from a response from a web server using kSOAP2 in Android...

我已经保存的反应形成一个SoapObject网络电话:

I've saved the response form the web call in a SoapObject:

SoapObject sResult = (SoapObject)envelope.bodyIn;

和我通过迭代的响应,并抢得价值

and I'm iterating through the response and grabbing the values

SoapObject soapresults = (SoapObject)sResult.getProperty(0);

for (int i = 0; i < count; i++)
{
    SoapObject mail = (SoapObject)soapresults.getProperty(i);

    /*Getting the values here*/   
}

一个邮件SoapObject将类似于这样:

A mail SoapObject will be similar to this:

MessageInstance = {anyType的AUTHORNAME =Børnehaven;
  CreatedAtUtc = 2012-04-10T18:30:00; ID = 631;消息体=果壳摩根我;
  收件人= {anyType的全名= NULL; ID = 2104535421; IsRead = TRUE;
  ReadAtUtc = 2012-04-10T18:30:00; }; };

MessageInstance=anyType{AuthorName=Børnehaven; CreatedAtUtc=2012-04-10T18:30:00; Id=631; MessageBody=Husk i morgen; Recipient=anyType{FullName=null; Id=2104535421; IsRead=true; ReadAtUtc=2012-04-10T18:30:00; }; };

和我有麻烦抓住了唯一的价值就是IsRead的价值,这是我希望保存为一个布尔...

And the only value I'm having trouble grabbing is the "IsRead" value, which I want to store as a boolean...

我试过几件事情:

(Boolean)mail.getProperty("IsRead");
((Boolean) mail.getProperty("IsRead")).booleanValue();

不过,我不断收到:

But I keep getting:

W / System.err的(1283):了java.lang.RuntimeException:非法财物:
  IsRead

W/System.err(1283): java.lang.RuntimeException: illegal property: IsRead

什么是得到它的正确方法是什么?

What is the correct way of getting it?

推荐答案

试试这个code片断:

Try this code snippet:

SoapObject soRecipient = (SoapObject) mail.getProperty("Recipient");

boolean isRead = Boolean.parseBoolean(soRecipient.getPropertyAsString("IsRead"));
String fullName = soRecipient.getPropertyAsString("FullName");
String id = soRecipient.getPropertyAsString("Id");
String readAtUtc = soRecipient.getPropertyAsString("ReadAtUtc");

这篇关于得到SoapObject布尔(kSOAP2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆