Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Android中解析KSOAP2响应?_Android_Web Services_Ksoap2_Android Ksoap2 - Fatal编程技术网

如何在Android中解析KSOAP2响应?

如何在Android中解析KSOAP2响应?,android,web-services,ksoap2,android-ksoap2,Android,Web Services,Ksoap2,Android Ksoap2,我在Android中使用KSoap2调用了一个Web服务,但得到的响应如下。如何在Android中解析这个ksoap响应 ResolveNamesResponse{ResponseMessages=anyType{ResolveNamesResponseMessage=anyType{MessageText=Multiple 结果被发现;ResponseCode=ErrorNameResolutionMultipleResults; DescriptiveLinkKey=0; Resolutio

我在Android中使用KSoap2调用了一个Web服务,但得到的响应如下。如何在Android中解析这个ksoap响应

ResolveNamesResponse{ResponseMessages=anyType{ResolveNamesResponseMessage=anyType{MessageText=Multiple 结果被发现;ResponseCode=ErrorNameResolutionMultipleResults; DescriptiveLinkKey=0; ResolutionSet=anyType{Resolution=anyType{Mailbox=anyType{Name=Amyj; 电子邮件地址=Amyj@testsa.onmicrosoft.com;RoutingType=SMTP; MailboxType=Mailbox;};Contact=anyType{DisplayName=Amy John; 吉文纳姆=艾米; EmailAddresses=anyType{Entry=SIP:Amyj@test.onmicrosoft.com; 条目=SMTP:Amyj@testsa.onmicrosoft.com; }; 物理地址=anyType{Entry=anyType{CountryOrRegion=China;};}; ContactSource=ActiveDirectory;姓氏=John;};}; 解析=anyType{Mailbox=anyType{Name=Amyraj; 电子邮件地址=Amyraj@testsa.onmicrosoft.com;RoutingType=SMTP; MailboxType=Mailbox;};Contact=anyType{DisplayName=Amy Raj; 吉文纳姆=艾米; EmailAddresses=anyType{Entry=SIP:Amyraj@testsa.onmicrosoft.com; 条目=SMTP:Amyraj@testsa.onmicrosoft.com; }; PhysicalAddresses=anyType{Entry=anyType{CountryOrRegion=India;};}; ContactSource=ActiveDirectory;姓氏=Raj;};}; 分辨率=anyType{Mailbox=anyType{Name=shine; 电子邮件地址=shine@testsa.onmicrosoft.com;RoutingType=SMTP; MailboxType=Mailbox;};Contact=anyType{DisplayName=seeph; GivenName=发光; EmailAddresses=anyType{Entry=SIP:shine@testsa.onmicrosoft.com; 条目=SMTP:shine@testsa.onmicrosoft.com; }; PhysicalAddresses=anyType{Entry=anyType{CountryOrRegion=India;};}; ContactSource=ActiveDirectory;姓氏=Joseph;};};};};};};};};};};}


实际上,如果您知道Java脚本,那么这是一种已知的格式。这种格式的数据实际上是JSON对象和JSON数组的

例如:

private Bundle bundleResult=new Bundle();
私有JSONObject JSONObject;
私人JSONArray JSONArr;
私有SoapObject resultSOAP=(SoapObject)信封。getResponse();
/*获取JSON字符串中的结果*/
私有字符串ResultObject=resultSOAP.getProperty(0.toString();
if(ResultObject.startsWith(“{”){//如果JSON字符串是对象
JSONObj=新的JSONObject(ResultObject);
迭代器itr=JSONObj.keys();
while(itr.hasNext()){
字符串键=(字符串)itr.next();
字符串值=JSONObj.getString(键);
bundleResult.putString(键、值);
//System.out.println(bundleResult.getString(Key));
}
}else if(ResultObject.startsWith(“[”){//如果JSON字符串是数组
JSONArr=新JSONArray(ResultObject);
System.out.println(“length”+JSONArr.length());
for(int i=0;i

我希望这能帮助你解决问题。

试试这个,我想它会管用的

SoapObject response = (SoapObject) envelope.getResponse();

int cols = response.getPropertyCount();

for (int i = 0; i < cols; i++) {

    Object objectResponse = (Object) response.getProperty(i);
    SoapObject r =(SoapObject) objectResponse;

    String   key1=(String) r.getProperty("key1").toString();

    // Get the rest of your Properties by 
    // (String) r.getProperty("PropertyName").toString();            
}
SoapObject response=(SoapObject)envelope.getResponse();
int cols=response.getPropertyCount();
for(int i=0;i
SoapObject response = (SoapObject) envelope.getResponse();

int cols = response.getPropertyCount();

for (int i = 0; i < cols; i++) {

    Object objectResponse = (Object) response.getProperty(i);
    SoapObject r =(SoapObject) objectResponse;

    String   key1=(String) r.getProperty("key1").toString();

    // Get the rest of your Properties by 
    // (String) r.getProperty("PropertyName").toString();            
}