如何从Android Xamarin中的WebService SOAP检索List

时间:2015-09-26 22:21:25

标签: c# soap xamarin.android

这是我的WebService,它与DataBase连接,我希望使用Xamarin列出我的Android项目中的所有内容: 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;
    } 

哪个Sel类有三个道具:

    public String Curso { get; set; }
    public String Turno { get; set; }
    public String Semestre { get; set; }

我创建此类以使用某些条件在我的数据库中进行查询,在Windows Phone Works中如下:

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;
    }

并且工作正常,但在android中,我知道我将需要使用适配器来创建列表

ListBaseAdapter:

我想像在Windows Phone中那样做,首先通过条件进行查询,然后列出所有内容!

0 个答案:

没有答案