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 is : " + result);
} catch (Exception e) {
System.out.println("Exception : "+e.toString());
}
return result;
}
}
}
And my response in logcat is:
Result is :
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 to get RoleID
and RoleName
from this response.
I have tried with result.getAttribute(0)
and result.getProperty(0)
. But They didn't help. Also I have googled lot. Any help to parse this response will be highly appriciated.
Thank you.