Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/11/2008, 19:29
Avatar de DevCH
DevCH
 
Fecha de Ingreso: marzo-2003
Ubicación: Villahermosa, Tabasco, Mé
Mensajes: 60
Antigüedad: 21 años, 2 meses
Puntos: 0
Consumir un WebMethod de tipo Lista Generica

Hola a todos.

Pues resulta que tengo un webservice con un WebMethod tipo Lista Generica, mas o menos así:

[WebMethod(Description = "Lista Habilitaba para Combos 2")]
public List<lstCombo> get_lstCombo2(Int32 pTipo)
{
List<lstCombo> MyList = new List<lstCombo>();
SqlDataAdapter da;
DataSet dsTabla = new DataSet();
SqlCommand sc = new SqlCommand();

sc.Connection = sqlConn;
sc.CommandType = CommandType.StoredProcedure;
switch (pTipo)
{
case 1:
sc.CommandText = "llena_combo_get";
break;
}

OpenConnection();
da = new SqlDataAdapter(sc);
da.Fill(dsTabla);
CloseConnection();

if (dsTabla.Tables[0].Rows.Count > 0)
{
foreach (DataRow item in dsTabla.Tables[0].Rows)
{
lstCombo registro = new lstCombo();
registro.data = (Int32)item["data"];
registro.label = (string)item["label"];
MyList.Add(registro);
}
}
else
{
lstCombo registro = new lstCombo();
registro.data = 0;
registro.label = "Ninguno";
MyList.Add(registro);
}

return MyList;
}


Y desde un una Aplicación Windows hecha tambien con C#, no se como invocarla e intentado de esta forma:

ExalAr.WS.exalar ws = new ExalAr.WS.exalar();
Lista lst = ws.ws.get_lstCombo2(1)

me devuelve el siguiente error:

Error 1 Cannot implicitly convert type 'ExalAr.WS.lstCombo[]' to 'Lista' C:\Working.NET\ExalAr\ExalAr\Controlador.cs 116 25 ExAlAr

______________________
LISTA es una clase:

using System;
using System.Collections.Generic;
using System.Text;

public class Lista
{
public Lista() { }

Int32 _data = 0;
string _label = "";

public Int32 data
{
set { _data = value; }
get { return _data; }
}

public string label
{
set { _label = value; }
get { return _label; }
}


}
______________________________
listCombo tiene la misma estructura

_________________________________
que será que puede estar pasando, el WS lo he probado desde el web y si funciona bien, pero no se como recoibir los datos devueltos en un Form de C#

Les agradezco toda la ayuda que me puedan brindar...

Saludos
__________________
Carlos Hidalgo
[email protected]
Villahermosa, Tabasco, México.

"Locura es: Obtener siempre el mismo resultado, y seguir insistendo con lo mismo, esperando que algún día, algo nuevo suceda."

--Albert Einstein--

:si: