1.首先,运行你的WebService(Ctrl+F5直接运行),把跳出的浏览器的地址栏复制。
2.然后,在WinForm的解决方案资源管理器中右击引用-添加Web引用,在URL中粘帖刚复制的地址。并输入web引用名。
3.在WinForm的程序中,先添加using
using 项目命名空间.web引用名;
4.然后在WinForm的程序中,实例化webservice
我的WebService是Service1.asmx,其中的WebMethod是
[WebMethod] public string Business(String msg) { }
所以在WinForm的程序中添加的如下:
Service1 service1 = new Service1(); String result = service1.Business(msg);