C# Builder构建Web服务和客户端
http://tech.ddvip.com 2006年08月01日 社区交流
本文详细介绍C# Builder构建Web服务和客户端

改变你的*.asmx和*.asmx.cs的Web方法(WebService1)的默认名为DOW。 此外,添加下面的属性(使用你的名称替换我的)。
public class DOW: System.Web.Services.WebService:
[WebService(Namespace="http://www.ClayShannon.com")
删除DOW.asmx.cs文件中的位置标志符web methods(注释掉),并且在unit的底部添加下面的方法和属性:
[WebMethod]
public string GetDow(int intYear, int intMonth, int intDay)
{
DateTime d8 = new DateTime(intYear, intMonth, intDay, new GregorianCalendar());
GregorianCalendar gregCal = new GregorianCalendar();
return gregCal.GetDayOfWeek(d8).ToString();
}
此外,在unit的顶部添加下面的代码:
Using System.Globalization;
现在,当你运行这个应用程序的时候,你将在你的web浏览器中看到下面这个屏幕:

单击ServiceDescription,显示Web方法后的SOAP XML:

单击GetDow显示这个页面:

C# Builder允许你从Web方法/服务本身测试你的Web方法。 你不必首先创建一个客户端来测试它,这样多省时间呀,因为不这样的话你就要在Web服务工程和客户端工程之间来回切换。
责编:豆豆技术应用