I am Connecting to .NET web-service in android.and For login I used the code
Login method:
public void logingin(View vvvv){
if(Utils.CheckNet(contect)) {
cv=new ContentValues();
cv.put("process", "login");
cv.put("username", uname);
cv.put("password",pass);
flage = true;
showConnectingProgreesDialog(contect,true,"Connecting to server");
new Thread(){
public void run(){
response=Utils.postDataToServer("api_lgn", cv);
mHandler.post(showDimage);
}
}.start();
} else {
Toast.makeText(contect, "Requires Network Connectivity", Toast.LENGTH_LONG).show();
}
and class that posts the Contents is:
public static String postDataToServer(String pagename,
ContentValues postcontents) {
try {
String u = weburl + pagename;
Log.i("url", u);
org.apache.http.client.HttpClient cl = new DefaultHttpClient();
org.apache.http.client.methods.HttpPost req = new org.apache.http.client.methods.HttpPost(
u);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(
postcontents.size());
Set<Entry<String, Object>> t = postcontents.valueSet();
for (Entry<String, Object> entry : t) {
nameValuePairs.add(new BasicNameValuePair(entry.getKey()
.toString(), entry.getValue().toString()));
}
req.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse resp = cl.execute(req);
Log.i("http post request`", req.getURI().getPath().toString());
BufferedReader reader = new BufferedReader(new InputStreamReader(resp
.getEntity().getContent()));
if (reader != null) {
StringBuilder sb=new StringBuilder();
String line=null;
while((line=reader.readLine())!=null){
sb.append(line);
}
Log.d("post_response", sb.toString());
return sb.toString();
}
Log.d("post_response null", reader.readLine()+" ");
} catch (Exception e) {
Log.d("@utils.unamepswd", e.toString());
}
return "";
}
And the response is :
<?xml version="1.0" encoding="utf-8"?><string xmlns="http://tempuri.org/ { Result : Success , Id : 1 , UserName : Myname , Password :null} /string>
The Problem is that I don't know how to get the Result,id,Username and password From this Format. Please Help To do this...
Thanks...