androidxmlsoapksoap

Is there any way to parse this soap response?


My Code

protected void getComplaits(String Payroll_no) {
    SoapObject request = new SoapObject(sd.NAMESPACE, sd.GET_COMPLAINTS_LIST);
    PropertyInfo Payroll_info = new PropertyInfo();
    Payroll_info.setName("Payroll_no");
    Payroll_info.setValue(Payroll_no);
    Payroll_info.setType(double.class);
    request.addProperty(Payroll_info);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);
    HttpTransportSE androidHttpTransport = new HttpTransportSE(sd.URL);
    try {
        androidHttpTransport.call(sd.GET_COMPLAINTS_LIST_SOAP_ACTION, envelope);
        SoapObject result = (SoapObject) envelope.bodyIn;
        result1 =result.toString();

    } catch (Exception e) {
        result1 = e.toString();
    }

}

This is My Soap Response

Get_Complaints_listResponse
{Get_Complaints_listResult=anyType
{schema=anyType
{element=anyType
{complexType=anyType
{choice=anyType
{element=anyType
{complexType=anyType
{sequence=anyType
{element=anyType{}; element=anyType {}; element=anyType{}; element=anyType{}; 
}; 
}; 
}; 
}; 
}; 
}; 
}; 
diffgram=anyType
{DocumentElement=anyType
{
Complaints_list=anyType{
COMPLAINT_NO=5951113; COMPLAINT_TYPE=NSI; CONSUMER_TYPE=M; COMPLAINT_TIME=0500; }; 

Complaints_list=anyType{
COMPLAINT_NO=403730614; COMPLAINT_TYPE=VLF; CONSUMER_TYPE=M; COMPLAINT_TIME=2340; };
}; 
}; 
};
}

How should I get Only COMPLAINT_NO,COMPLAINT_TYPE,CONSUMER_TYPE,COMPLAINT_TIME data. I already Try Parsing But it not work,Please Guide!!!

How should i get The Data from This field ,is there any library which provide these method to extract Data!!


Solution

  • I Found Out Solution after reading several post. Thank you , Stack overflow Members

     try {
            androidHttpTransport.call(sd.GET_COMPLAINTS_LIST_SOAP_ACTION, envelope);
            SoapObject root = (SoapObject) envelope.bodyIn;
            SoapObject t = (SoapObject)root.getProperty(0);
            SoapObject t1 = (SoapObject)t.getProperty(1);
            SoapObject t2 = (SoapObject)t1.getProperty(0);
    
    
            for(int i = 0;i < t2.getPropertyCount();i++)
            {
                SoapObject Complaint_list = (SoapObject) t2.getProperty(i);
                SoapPrimitive complaint_no = (SoapPrimitive)Complaint_list.getProperty(0);
                SoapPrimitive complaint_type = (SoapPrimitive)Complaint_list.getProperty(1);
                SoapPrimitive consumer_type = (SoapPrimitive)Complaint_list.getProperty(2);
                SoapPrimitive complaint_time = (SoapPrimitive)Complaint_list.getProperty(3);
    
                Log.i("complaint_no",complaint_no.toString());
                Log.i("complaint_type",complaint_type.toString());
                Log.i("consumer_type",consumer_type.toString());
                Log.i("complaint_time",consumer_type.toString());
    
            }
        } catch (Exception e) {
            result1 = e.toString();
        }