wcf - Parsing SoapObject Responst in android -


my code is:

public class mainactivity extends activity implements onclicklistener {  button b; private static string namespace = "http://tempuri.org/"; private static string method_name = "getlist"; private static string soap_action = "http://tempuri.org/iwcfmasterrole/getlist"; private static string url = "http://172.16.0.1:55355/wcfmasterrole.svc";  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      b = (button) findviewbyid(r.id.button1);     b.setonclicklistener(this); }  @override public void onclick(view v) {     if (v.getid() == r.id.button1) {         new myclass().execute("");     } }  class myclass extends asynctask<string, void, soapobject> {     soapobject result;     @override     protected soapobject doinbackground(string... params) {         try {              soapobject request = new soapobject(namespace, method_name);             // request.addproperty("cityid", "city0001");             soapserializationenvelope envelope = new soapserializationenvelope(                     soapenvelope.ver11);             envelope.setoutputsoapobject(request);             httptransportse transport = new httptransportse(url);             try {                 transport.call(soap_action, envelope);             } catch (exception e) {                 e.printstacktrace();             }             result = (soapobject) envelope.bodyin;             system.out.println("result : " + result);         } catch (exception e) {             system.out.println("exception : "+e.tostring());         }          return result;     } } } 

and response in logcat is:

    result :  getlistresponse  {    getlistresult=anytype    {schema=anytype     {element=anytype      {complextype=anytype       {choice=anytype        {element=anytype         {complextype=anytype          {sequence=anytype           {element=anytype{}; element=anytype{}; element=anytype{};            };           };          };         };        };       };      };      diffgram=anytype     {documentelement=anytype      {table1=anytype        {roleid=roleaaaa0000; rolename=administrator; };        table1=anytype       {roleid=roleaaaa0001; rolename=developer; };        table1=anytype       {roleid=roleaaaa0003; rolename=senior developer; };       table1=anytype       {roleid=roleaaaa0004; rolename=junior developer; };        table1=anytype       {roleid=roleaaaa0005; rolename=trainee; };        };     };    };  } 

i want roleid , rolename response.

i have tried result.getattribute(0) , result.getproperty(0). didn't help. have googled lot. parse response highly appriciated.

thank you.

basicly it's this:

soapobject getlistresponse = (soapobject)result.getproperty(0);  soapobject documentelement = (soapobject)getlistresponse.getproperty(3); soapobject table1 = (soapobject)documentelement.getproperty(0); 

this contains soapobjects within soapobjects, best thing write recursive method scan through properties , find information need. this:

private static void scansoapobject(soapobject result)  {     for(int i=0;i<result.getpropertycount();i++)     {         if(result.getproperty(i) instanceof soapobject)         {                             scansoapobject((soapobject)result.getproperty(i));         }         else         {                            //do current property              //get current property name:             propertyinfo pi = new propertyinfo();             result.getpropertyinfo(i,pi);             string name = pi.getname();         }     } } 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -