二.修改配置文件
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
<add name="HttpSoap"/>
<add name="Documentation"/>
</protocols>
</webServices>
</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;
}
四.客户端调用public IList getList()
{
IList list = new ArrayList();
list.Add("a");
list.Add("b");
return list;
}
//声明DOC
var 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);
}
var 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);
}