WebService学习总结
1.Webservice
可返回类型
int,string,double,bool,DataTable,DataSet,ArraList,List<string[]>,string[],void,Guid,序列化的自定义对象(类名上加上[Serializable]标识)
可传递参数
序列化的对象,int,string,double,bool,List<string[]>,byte[],Guid,out int
[WebMethod]
public string Send(SendData item)
{
}
2.webservices发布时,需要在web.config中的<system.web>节点中添加如下配置,否则无法正常调用
<webServices>
<protocols>
<add name="HttpPost"/>
<add name="HttpGet"/>
</protocols>
</webServices>
特别注意:
1.不能有方法重写,方法名必须唯一,否则不能添加web引用
2.webservice方法不能加static修饰,否则引用中找不到需要的方法
3.webservice方法前一定要有[WebMethod],否则也找不到
4.返回类型是DataTable的时候,DataTable一定要有名字,否则程序运行中报错

浙公网安备 33010602011771号