是的,您可以这样做:
如果您的回答与以下类似:
anyType{
StatusSetting=anyType{Id=1; Name=Til afskrivning; LocationId=1; Editable=true; Default=true; Transcribed=false; };
StatusSetting=anyType{Id=2; Name=Afskrevet; LocationId=1; Editable=false; Default=false; Transcribed=true; };
...
}
然后你必须这样做:
SoapObject countryDetails = (SoapObject)envelope.getResponse();
System.out.println(countryDetails.toString());
ArrayList list = new ArrayList(countryDetails.getPropertyCount());
lv_arr = new String[countryDetails.getPropertyCount()];
for (int i = 0; i < countryDetails.getPropertyCount(); i++) {
object property = countryDetails.getProperty(i);
if (property instanceof SoapObject) {
SoapObject countryObj = (SoapObject) property;
String countryName = countryObj.getProperty("countryName").toString();
list.add(countryName );
}
}
如果你能通过这个例子理解,请告诉我;否则,我会将您响应的数据解析代码发送给您。
或其他:
您只需添加以下内容即可从 soap 对象获取 XML 响应:
androidHttpTransport.debug = true;
在通话之前:
androidHttpTransport.call(SOAP_ACTION, envelope);
并添加:
String xml = androidHttpTransport.responseDump;
通话后。
您将把 XML 放在字符串 XML 中。因此,您可以使用任何(DOM、xmlpull 或 SAX)解析器对其进行解析。
您可以按照以下代码来完成任务:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
// Add the input required by web service
request.addProperty("city","chennai");
request.addProperty("key","10000");
SoapSerializationEnvelope envelope =new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
// Make the soap call.
androidHttpTransport.call(SOAP_ACTION, envelope);
// Get the SoapResult from the envelope body.
resultRequestSOAP = (SoapObject) envelope.bodyIn;
System.out.println("********Response : "+resultRequestSOAP.toString());
SoapObject root = (SoapObject) resultRequestSOAP.getProperty(0);
SoapObject s_deals = (SoapObject) root.getProperty("FOO_DEALS");
StringBuilder stringBuilder = new StringBuilder();
System.out.println("********Count : "+ s_deals.getPropertyCount());
for (int i = 0; i < s_deals.getPropertyCount(); i++)
{
Object property = s_deals.getProperty(i);
if (property instanceof SoapObject)
{
SoapObject category_list = (SoapObject) property;
String CATEGORY = category_list.getProperty("CATEGORY").toString();
String CATEGORY_URL = category_list.getProperty("CATEGORY_URL").toString();
String CATEGORY_ICON = category_list.getProperty("CATEGORY_ICON").toString();
String CATEGORY_COUNT = category_list.getProperty("CATEGORY_COUNT").toString();
String SUPERTAG = category_list.getProperty("SUPERTAG").toString();
String TYPE = category_list.getProperty("TYPE").toString();
stringBuilder.append
(
"Row value of: " +(i+1)+"\n"+
"Category: "+CATEGORY+"\n"+
"Category URL: "+CATEGORY_URL+"\n"+
"Category_Icon: "+CATEGORY_ICON+"\n"+
"Category_Count: "+CATEGORY_COUNT+"\n"+
"SuperTag: "+SUPERTAG+"\n"+
"Type: "+TYPE+"\n"+
"******************************"
);
stringBuilder.append("\n");
}
}