How to handle Soap result in Android..?

174 views Asked by At

My Soap result is in the form as below. Since the result is a Soap object.

11-27 17:14:48.310: I/TAG(3771): message=========================getProdResponse{return=[unnamed_struct_use_soapval{id=57; }, unnamed_struct_use_soapval{id=77; }]; }
11-27 17:14:48.310: I/TAG(3771): message=========================[unnamed_struct_use_soapval{id=57; }, unnamed_struct_use_soapval{id=77; }]
11-27 17:14:48.310: I/TAG(3771): nameResult=================[unnamed_struct_use_soapval{id=57; }, unnamed_struct_use_soapval{id=77; }]

I am getting two ID values here in the above log. id= 77 and id = 57. How can I get only the id.

1

There are 1 answers

2
parthpatibandha On

If you are use SVC webservice than this code helps you... public class Test extends Activity {

private final String URL = "http://10.0.2.2:8116/Service1.svc?wsdl";
private final String NAMESPACE = "http://tempuri.org/";
 private final String SOAP_ACTION = "http://tempuri.org/IService1/GetData";
 private final String METHOD_NAME = "GetData";







@Override
protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    if (android.os.Build.VERSION.SDK_INT > 9) 
    {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }
    setContentView(R.layout.activity_test);








            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);



            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet = true;
            envelope.setOutputSoapObject(request);
            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

            try {

                androidHttpTransport.call(SOAP_ACTION, envelope);
                SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
                Log.i("myApp_Responce...", response.toString());


                TextView tv= (TextView)findViewById(R.id.hello);
                tv.setText(response.toString());



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

        }                                                                                Always Add your ksoap jar manually in project workspace.