WebService与List
在WebService定义一个List集合参数,为什么到了客户端引用的时候就成了一个数组呢?
错误1与“Eis.Portal.Isdk.IAccess.ExecuteDataTable(string, Eis.Portal.Isdk.CommandType, string, Eis.Portal.Isdk.ListPara[])”最匹配的重载方法具有一些无效参数E:\Web\EIS\EisPortal\Default.aspx.cs7144EisPortal
private void LoadUser() { try { strSQL = "SELECT * FROM LoginUser where UserName like @UserName and password like @password"; IAccess access = new IAccess(); List<ListPara> list = new List<ListPara>(); ListPara lp = new ListPara(); lp.para = "UserName"; lp.value = "A"; list.Add(lp); lp.para = "Password"; lp.value = "123456"; list.Add(lp); //list.Add(new ListPara("UserName", "A")); //list.Add(new ListPara("Password", "123456")); System.Data.DataTable dt = access.ExecuteDataTable(guid, Eis.Portal.Isdk.CommandType.Text, strSQL,list);//List集合??? this.gvUser.DataSource = dt; this.gvUser.DataBind(); } catch (Exception ex) { throw ex; } }
namespace EIS.ISdk{ /// <summary> /// IAceess 的摘要说明 /// </summary> [WebService(Namespace = "http://eissdk.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.None)] [System.ComponentModel.ToolboxItem(false)] // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。 // [System.Web.Script.Services.ScriptService] public class IAccess : System.Web.Services.WebService { [WebMethod(MessageName = "ExecuteDataTable", Description = "Return Execute Data Table")] public DataTable ExecuteDataTable(string guid, CommandType cmdType, string cmdText) { if (LoginAuth.GuidAuth(guid)) { List<ListPara> list = new List<ListPara>(); list.Add(new ListPara("UserName", "A")); list.Add(new ListPara("Password", "123456")); return SqlHelper.ExecuteDataTable(cmdType, cmdText, SqlHelper.GetParameters(list)); } else { return null; } } [WebMethod(MessageName = "ExecuteDataTable2", Description = "Return Execute Data Table")] public DataTable ExecuteDataTable(string guid, CommandType cmdType, string cmdText,List<ListPara> list) { if (LoginAuth.GuidAuth(guid)) { return SqlHelper.ExecuteDataTable(cmdType, cmdText, SqlHelper.GetParameters(list)); } else { return null; } }}