How to retrieve a List from WebService SOAP in Android Xamarin

this is my WebService which is connected with a DataBase and i want to list all that in my Android Project using Xamarin: WebService :
`public string ConnectionString = ConfigurationManager.ConnectionStrings["DjConnectionString"].ConnectionString;

[WebMethod]
public List<Clientes> Clientes(/*string _curso, string _turno, string _semestre*/ Sel _sel)
{
    string Select = "select Nome,Menssagem from Faculdade where Curso = " + _sel.Curso + " AND Turno = " + _sel.Turno + " AND Semestre =" + _sel.Semestre;

    List<Clientes> clientes = new List<Clientes>();

    using (SqlConnection conexao = new SqlConnection(ConnectionString))
    {
        using (SqlCommand command = new SqlCommand(Select, conexao))
        {
            conexao.Open();
            SqlDataReader dataReader = command.ExecuteReader();
            if (dataReader.HasRows)
            {
                while (dataReader.Read())
                {
                    Clientes cliente = new Clientes();
                    cliente.Nome = dataReader["Nome"].ToString();
                    cliente.Menssagem = dataReader["Menssagem"].ToString();
                    clientes.Add(cliente);
                }
            }
            conexao.Dispose();
        }
    }
    return clientes;
} `

Which Sel class has three props :
public String Curso { get; set; } public String Turno { get; set; } public String Semestre { get; set; }

I create this class to use some conditions to make a query in my database, in Windows Phone Works like that :
`public MainPage()....{

    Service.Sel sel = new Service.Sel();
    sel.Curso = "'CCO'";
    sel.Turno = "'Manha'";
    sel.Semestre = "'2015'";
    Service.WebServiceSoapClient cliente = new Service.WebServiceSoapClient();
    cliente.ClientesAsync(sel);
    cliente.ClientesCompleted += Cliente_ClientesCompleted;

}
private void Cliente_ClientesCompleted(object sender, Service.ClientesCompletedEventArgs e)
{
lbLista.ItemsSource = e.Result;
}`

And Works fine,but in android, i know i will need to use a Adapter to create a list
ListBaseAdapter:

I want to do the same way there i did in Windows Phone, first past the conditions to make a query and then list all!

Answers

Sign In or Register to comment.