一. 建WebService.asmx 二.修改配置文件<system.web> <webServices> <protocols> <add name="HttpGet"/> <add name="HttpPost"/> <add name="HttpSoap"/> <add name="Documentation"/> </protocols> </webServices> </system.web> 三.WebService.cs添加方法: [WebMethod] //标志 ,必填public IList getList(){ IList list = new ArrayList(); list.Add("a"); list.Add("b"); return list;} 四.客户端调用 //声明DOCvar doc;if (window.ActiveXObject){ doc = new ActiveXObject("Microsoft.XMLDOM");}else{ if (document.implementation&&document.implementation.createDocument) { doc = document.implementation.createDocument("","doc",null); }}doc.async = "false";//xmlDom.preserveWhiteSpace=true; //是否保留空格window.onload = function(){ doc.load("http://localhost:4863/WebService1.asmx/getList"); var arr = doc.text; alert(arr);} 转载于:https://www.cnblogs.com/di305449473/archive/2008/06/16/1223034.html