WebMethodAttribute クラスとは? わかりやすく解説

WebMethodAttribute クラス

ASP.NET作成されXML Web サービス内でこの属性メソッド追加すると、リモートWeb クライアントから該当するメソッド呼び出すことができます。このクラス継承できません。

名前空間: System.Web.Services
アセンブリ: System.Web.Services (system.web.services.dll 内)
構文構文

<AttributeUsageAttribute(AttributeTargets.Method)> _
Public NotInheritable Class
 WebMethodAttribute
    Inherits Attribute
Dim instance As WebMethodAttribute
[AttributeUsageAttribute(AttributeTargets.Method)] 
public sealed class WebMethodAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Method)] 
public ref class WebMethodAttribute sealed
 : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Method) */ 
public final class WebMethodAttribute extends
 Attribute
AttributeUsageAttribute(AttributeTargets.Method) 
public final class WebMethodAttribute extends
 Attribute
解説解説
使用例使用例

WebMethodAttribute設定されているためメソッド GetMachineNameWeb 経由リモートから呼び出すことができる例を次に示しますGetUserNamepublic ですが、WebMethodAttribute設定されていないためリモートから呼び出すことはできません。

<%@ WebService Language="VB" Class="Util"%>

Imports System
Imports System.Web.Services

Public Class Util
    Inherits WebService
    
    Public Function GetUserName() As
 String
        Return User.Identity.Name
    End Function    
    
    <WebMethod(Description := "Obtains the Server Machine Name",
 _
        EnableSession := True)> _
    Public Function GetMachineName() As
 String
        
        Return Server.MachineName
    End Function
End Class

<%@ WebService Language="C#" Class="Util"%>
    using System;
    using System.Web.Services;
    public class Util: WebService {
       public string GetUserName() {
          return User.Identity.Name;
       }
    
       [ WebMethod(Description="Obtains the Server Machine Name",
       EnableSession=true)]
       public string GetMachineName() {
          return Server.MachineName;
       }
    }

継承階層継承階層
System.Object
   System.Attribute
    System.Web.Services.WebMethodAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebMethodAttribute メンバ
System.Web.Services 名前空間
TransactionOption
WebService



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「WebMethodAttribute クラス」の関連用語

WebMethodAttribute クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



WebMethodAttribute クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS