看到一片关于类基础知识的文章,收集起来大家看一下。
System.Web.Services Namespace包括许多类,使得程序员更加方便地利用ASP.NET和XML Web Service客户端来创建XML Web服务。System.Web.Service的类层次。 类 描述 WebMethodAttribute 这个类不可被继承,将此属性添加到ASP.NET方法中,则使该方法可以随时被远程Web客户端调用WebService 定义了XML的Web Services的可选的基类,该基类提供直接访问的ASP.NET对象,如前面我们讲过的application和session WebServiceAttribute 常用于添加附加信息到XML Web Service中WebServiceBindingAttribute 声明绑定一个或者多个在XML Web Service中的实现方法。这个类同样不能被继承 注意假如不需要访问AsP.NET的对象,那么即使不继承w_ebseVice也可以创 建一个XML Web Service。 这个ASP.NET对象可以通过上下文采访问。XML Web Service方法将单一的性质,如SoapRpcMethodAttribute或者SoapDocument.Meth odAttribute的值设为True,这样,这些方法就不用访问它们的HttpContext。同样地,访问Web Service类的任意一个属性,都可以通过XML Web Service方法返回一个表示空的指针 例如,利用一个时间函数DateTime.Now.ToShortTimeString通过访问Web Service来得到服务器的时间,并且利用Context属性得到该值。 <%@WebSerVice Language="VB "Class="UtilTime" %> Imports System Imports System.Web.Services Public Class UtilTime Inherits WebService <WebMethod(Description:=”Returns the time as stored on the Server”, EnableSession:=FalseL> Public Function Time()As String Return Context.Timestamp.TimeOfDay.ToString() End Function
|