communicating android client with wcf service
===

Im new to android and want to connect my android client to remote sql server. pls help me. here is my wcf & client code :


IService1.cs

namespace WcfService4Login
{
   
    [ServiceContract]
    public interface ILogin
    {
        [OperationContract]
        bool GetUserDetails(string Username, string pwd);

        // TODO: Add your service operations here
    }

    
    [DataContract]
    public class UserDetails
    {
        string username = string.Empty;
        string pwd = string.Empty;

        [DataMember]
        public string UserName
        {
            get { return username; }
            set { username = value; }
        }
        [DataMember]
        public string Pwd
        {
            get { return pwd; }
            set { pwd = value; }
        }

      
    }
}


--------------------------------


Service1.cs



 public class Login : ILogin
    {

        SqlConnection con = new SqlConnection("Data Source=1.2.3.4;Initial Catalog=test;User ID=test;Password=test");

        public bool GetUserDetails(string Username, string pwd)
        {
            con.Open();
            SqlCommand cmd = new SqlCommand("select username,password from User where UserName = '" + Username + "' and password = '" + pwd + "'", con);
            cmd.Parameters.AddWithValue("@Name", Username);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            if (dt.Rows.Count != 0)
            {
                con.Close();
                return true;
            }
            con.Close();
            return false;
        }
    }

-------------------------------
Android Client :
 private boolean postLoginData()
    
    {
DefaultHttpClient httpClient = new DefaultHttpClient();
    	    	
    	
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("http://127.0.0.1/LoginServiceSite/Login.svc/GetUserDetails");
		try {

		List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
			nameValuePairs.add(new BasicNameValuePair("admin", "admin"));
			nameValuePairs.add(new BasicNameValuePair("Passwd", "pwd"));
	

			post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
			HttpResponse response = client.execute(post);
			BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

			String line = "";
			while ((line = rd.readLine()) != null) 
			{
				System.out.println(line);
				if (line.startsWith("Auth=")) {
					String key = line.substring(5);
					// Do something with the key
					return true;
				}
				
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return false;
}

