using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
namespace lhswebservice
{
//[WebService(Namespace = "http://tempuri.org/")]
[WebService(Namespace = "http://192.168.100.155/PrecompiledWeb/")] //"http://microsoft.com/webservices/"
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service()
{
//如果使用設計的元件,請取消注釋以下行
//InitializeComponent();
}
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public int Add(int a, int b)
{
return (a + b);
}
}
}
-------------------------------
右鍵單擊右邊的reference(引用),選擇”添加引用”,選擇浏覽,找到webserver目錄下的bin目錄下的App_Code.dll
再加入一個system.web.webservices的引用,在清單中有。
-----------------------------
lhswebservice.Service aa = new lhswebservice.Service();
int iaa=aa.Add(2,2);
int ibb = aa.Add(2, 2);
----這是本地調用方式