WebService クラス
アセンブリ: System.Web.Services (system.web.services.dll 内)
構文
Public Class WebService Inherits MarshalByValueComponent
public class WebService : MarshalByValueComponent
public class WebService extends MarshalByValueComponent
public class WebService extends MarshalByValueComponent
共通 ASP.NET オブジェクトにアクセスする必要がない場合は、WebService から派生させずに XML Web サービスを作成できます。追加の ASP.NET オブジェクトには、Context を使用してアクセスできます。
SoapRpcMethodAttribute または SoapDocumentMethodAttribute の OneWay プロパティが true に設定されている XML Web サービス メソッドは、その HttpContext へのアクセス権がありません。そのため、該当の XML Web サービス メソッド内から WebService クラスのどのプロパティにアクセスしても null 参照 (Visual Basic では Nothing) が返されます。
使用している .NET Framework Version 1.0 XML Web サービスのメソッドに SoapRpcMethodAttribute 属性または SoapDocumentMethodAttribute 属性が適用されており、OneWay プロパティが true に設定されている場合は、静的な Current プロパティを使用して HttpContext にアクセスしないでください。HttpContext にアクセスするには、XML Web サービスのメソッドを実装するクラスを WebService から派生し、Context プロパティにアクセスします。
Context プロパティを使用して、サーバーでの要求時刻を取得するために、WebService から派生して XML Web サービスを作成する例を次に示します。
<%@ WebService Language="VB" Class="Util" %> Imports System Imports System.Web.Services Public Class Util Inherits WebService <WebMethod(Description := "Returns the time as stored on the Server", _ EnableSession := False)> _ Public Function Time() As String Return Context.Timestamp.TimeOfDay.ToString() End Function End Class
System.ComponentModel.MarshalByValueComponent
System.Web.Services.WebService
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- WebService クラスのページへのリンク