Estou precisando obter os dados de um webservice, ele esta consumindo direito, mais quando era 1 unico registro ele a rotina funcionava normalmente mais com mais registros como abaixo, não estou conseguindo desmontar o resultado.
SoapObject request = new SoapObject("http://tempuri.org/", METHOD_NAME);
String prod = "33";
PropertyInfo prodqtd =new PropertyInfo();
prodqtd.setName("UF");
prodqtd.setValue(prod);
prodqtd.setType(String.class);
request.addProperty(prodqtd);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE Ht = new HttpTransportSE (SITE);
//Ht.debug = true;
Ht.call(OPERATION, envelope);
SoapObject resultado = (SoapObject) envelope.bodyIn;
SoapObject response = (SoapObject)envelope.getResponse();
UFs ufs=new UFs();
try {
parseBusinessObject(response.getProperty(1).toString(), ufs);
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
}
A função que desmembra o resultado é a abaixo.
public static void parseBusinessObject(String input, Object output) throws NumberFormatException, IllegalArgumentException, IllegalAccessException, InstantiationException{
Class theClass = output.getClass();
Field[] fields = theClass.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
Type type=fields[i].getType();
fields[i].setAccessible(true);
//Tipo String
if (fields[i].getType().equals(String.class)) {
String tag = fields[i].getName() + "="; //"s" is for String in the above soap response example + field name for example Name = "sName"
if(input.contains(tag)){
String strValue = input.substring(input.indexOf(tag)+tag.length(), input.indexOf(";", input.indexOf(tag)));
if(strValue.length()!=0){
fields[i].set(output, strValue);
//Log.v(TAG, strValue);
}
}
}
//detect int or Integer
if (type.equals(Integer.TYPE) || type.equals(Integer.class)) {
String tag = fields[i].getName() + "="; //"i" is for Integer or int in the above soap response example+ field name for example Goals = "iGoals"
if(input.contains(tag)){
String strValue = input.substring(input.indexOf(tag)+tag.length(), input.indexOf(";", input.indexOf(tag)));
if(strValue.length()!=0){
fields[i].setInt(output, Integer.valueOf(strValue));
}
}
}
//detect float or Float
if (type.equals(Float.TYPE) || type.equals(Float.class)) {
String tag = fields[i].getName() + "=";
if(input.contains(tag)){
String strValue = input.substring(input.indexOf(tag)+tag.length(), input.indexOf(";", input.indexOf(tag)));
if(strValue.length()!=0){
fields[i].setFloat(output, Float.valueOf(strValue));
}
}
}
}
}
O Input está assim, quando era um registro.
08-01 15:41:07.683: V/ParseBogXML(658): anyType{NewDataSet=anyType{RetornaUF=anyType{COD_UF=12; NOM_UF=Acre; SIGLA_UF=AC; }; }; }
So que como agora tem que buscar tudo para alimentar o banco, ja tentei varias soluções e não consegui algo para processar o resultado abaixo.
Obs: To ainda medido em Java/Android, agradeço quem puder ajudar, pois preciso resolver isso para avançar na app.