看到一片關(guān)于類基礎(chǔ)知識(shí)的文章,收集起來大家看一下。
System.Web.Services Namespace包括許多類,使得程序員更加方便地利用ASP.NET和XML Web Service客戶端來創(chuàng)建XML Web服務(wù)。System.Web.Service的類層次。 類 描述 WebMethodAttribute 這個(gè)類不可被繼承,將此屬性添加到ASP.NET方法中,則使該方法可以隨時(shí)被遠(yuǎn)程Web客戶端調(diào)用WebService 定義了XML的Web Services的可選的基類,該基類提供直接訪問的ASP.NET對(duì)象,如前面我們講過的application和session WebServiceAttribute 常用于添加附加信息到XML Web Service中WebServiceBindingAttribute 聲明綁定一個(gè)或者多個(gè)在XML Web Service中的實(shí)現(xiàn)方法。這個(gè)類同樣不能被繼承 注意假如不需要訪問AsP.NET的對(duì)象,那么即使不繼承w_ebseVice也可以創(chuàng) 建一個(gè)XML Web Service。 這個(gè)ASP.NET對(duì)象可以通過上下文采訪問。XML Web Service方法將單一的性質(zhì),如SoapRpcMethodAttribute或者SoapDocument.Meth odAttribute的值設(shè)為True,這樣,這些方法就不用訪問它們的HttpContext。同樣地,訪問Web Service類的任意一個(gè)屬性,都可以通過XML Web Service方法返回一個(gè)表示空的指針 例如,利用一個(gè)時(shí)間函數(shù)DateTime.Now.ToShortTimeString通過訪問Web Service來得到服務(wù)器的時(shí)間,并且利用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
|