gpt4 book ai didi

android - 在 android 中解析 KSoap2 响应

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:49:58 26 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Parsing ksoap2 response

所以我设法在 android 中使用 KSoap2 调用网络服务,但我找不到解析响应的方法...

So here's what I receive from the webservice
anyType{
WORCCategoriaSubcategoriaRecord=anyType{ssENCategoria=anyType{Id=1; Nome=Problema na rua; }; ssENSubcategoria=anyType{Id=1; Nome=Falta de acesso; Imagem=anyType{}; CategoriaId=1; }; };

WORCCategoriaSubcategoriaRecord=anyType{ssENCategoria=anyType{Id=1; Nome=Problema na rua; }; ssENSubcategoria=anyType{Id=2; Nome=Falta de Passadeira; Imagem=anyType{}; CategoriaId=1; }; };
}

这是我用来调用网络服务的代码...

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
//request.addProperty("Celsius", "32");

SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
//soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(request);
soapEnvelope.dotNet = true;
AndroidHttpTransport aht = new AndroidHttpTransport(URL);
try{
aht.call(SOAP_ACTION, soapEnvelope);
//SoapPrimitive resultString = (SoapPrimitive)soapEnvelope.getResponse();
SoapObject resultsRequestSOAP = (SoapObject) soapEnvelope.bodyIn;
int elementCount = resultsRequestSOAP.getPropertyCount();

if(elementCount>0){
SoapObject element;
for(int i = 0;i<elementCount;i++){
element = (SoapObject)resultsRequestSOAP.getProperty(i);
}
}

}catch(Exception ex){
ex.printStackTrace();
}

有没有什么方法可以“轻松”解析它,而不必“手动”遍历每个属性?类似于 XML 解析器...

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com