WebServiceAttributeとは? わかりやすく解説

WebServiceAttribute クラス

XML Web サービスに追加情報 (機能を説明する文字列など) を追加するために使用します。

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

<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Interface)>
 _
Public NotInheritable Class
 WebServiceAttribute
    Inherits Attribute
Dim instance As WebServiceAttribute
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface)] 
public sealed class WebServiceAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class|AttributeTargets::Interface)] 
public ref class WebServiceAttribute sealed
 : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface)
 */ 
public final class WebServiceAttribute extends
 Attribute
AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface) 
public final class WebServiceAttribute extends
 Attribute
解説解説

WebServiceAttribute は、XML Web サービスを発行および実行するための必須クラスではありません。WebServiceAttribute を使用すると、XML Web サービスに対して、共通言語ランタイム識別子の規則によって制限されない名前を指定できます。この名前は、XML Web サービスのサービスの説明やサービス ヘルプ ページで使用されます。

XML Web サービスは、既定の XML 名前空間を変更してから公開する必要があります。クライアント アプリケーションが XML Web サービスを Web 上の他のサービスと区別できるように、各 XML Web サービスには、サービスを識別する固有の XML 名前空間が必要です。開発中の XML Web サービスには http://tempuri.org/ を使用できますが、発行された XML Web サービスではより永続的な名前空間を使用する必要があります。

XML Web サービスは、制御している XML 名前空間で識別する必要があります。たとえば、会社内のインターネット ドメイン名を XML 名前空間の一部として使用できます。多くの XML Web サービスの XML 名前空間は URL と似ていますが、XML 名前空間は Web 上の実際のリソースを指す必要はありません。XML Web サービスの XML 名前空間は URI です。ASP.NET で作成した XML Web サービスの場合、既定の XML 名前空間は Namespace プロパティを使用して変更できます。

属性の使用方法については、「属性を使用したメタデータの拡張」を参照してください。

使用例使用例

WebServiceAttribute の Description プロパティを "Common Server Variables" に設定し、XML 名前空間を http://www.microsoft.com/japan に設定する例を次に示します。

<%@ WebService Language="VB" Class=
 "ServerVariables"%>
 
Imports System
Imports System.Web.Services

<WebService(Description := "Common Server Variables",
 _
 Namespace := "http://www.contoso.com/")>
 _
Public Class ServerVariables
    Inherits WebService 
    
    <WebMethod(Description := "Obtains the Computer Machine
 Name", _
        EnableSession := False)> _
    Public Function GetMachineName() As
 String
        
        Return Server.MachineName
    End Function
End Class
 
<%@ WebService Language="C#" Class= "ServerVariables"%>
 
 using System;
 using System.Web.Services;
 
 [ WebService(Description="Common Server Variables",Namespace="http://www.contoso.com/")]
 public class ServerVariables: WebService {
 
 
    [ WebMethod(Description="Obtains the Server Computer Name",EnableSession=false)]
    public string GetMachineName() {
       return Server.MachineName;
    }   
 }
 
継承階層継承階層
System.Object
   System.Attribute
    System.Web.Services.WebServiceAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebServiceAttribute メンバ
System.Web.Services 名前空間
WebService クラス
WebMethodAttribute クラス
SoapDocumentMethodAttribute
SoapDocumentServiceAttribute
SoapRpcMethodAttribute
SoapRpcServiceAttribute

WebServiceAttribute コンストラクタ

WebServiceAttribute クラスの新しいインスタンスを初期化します。

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

Dim instance As New WebServiceAttribute
public WebServiceAttribute ()
public:
WebServiceAttribute ()
public WebServiceAttribute ()
public function WebServiceAttribute ()
使用例使用例
<%@ WebService Language="VB" class=
 "ServerVariables"%>
 
Imports System
Imports System.Web.Services
Imports System.Web.Services.Protocols

<WebService(Namespace := "http://www.contoso.com/")>
 _
Public Class ServerVariables
    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

<%@ WebService Language="C#" class= "ServerVariables"%>
 
 using System;
 using System.Web.Services;
 using System.Web.Services.Protocols;
 
 [ WebService(Namespace="http://www.contoso.com/")]
 public class ServerVariables: WebService {
    [ WebMethod(Description="Returns the time as stored on the Server"
,EnableSession=false)]
    public string Time() {
       return Context.Timestamp.TimeOfDay.ToString();
    }
 }
 
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebServiceAttribute クラス
WebServiceAttribute メンバ
System.Web.Services 名前空間

WebServiceAttribute フィールド


パブリック フィールドパブリック フィールド

  名前 説明
パブリック フィールド DefaultNamespace Namespace プロパティの既定値。このフィールドは定数です。
参照参照

関連項目

WebServiceAttribute クラス
System.Web.Services 名前空間
WebService クラス
WebMethodAttribute クラス
SoapDocumentMethodAttribute
SoapDocumentServiceAttribute
SoapRpcMethodAttribute
SoapRpcServiceAttribute

WebServiceAttribute プロパティ


パブリック プロパティパブリック プロパティ

参照参照

関連項目

WebServiceAttribute クラス
System.Web.Services 名前空間
WebService クラス
WebMethodAttribute クラス
SoapDocumentMethodAttribute
SoapDocumentServiceAttribute
SoapRpcMethodAttribute
SoapRpcServiceAttribute

WebServiceAttribute メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Equals  オーバーロードされます。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttribute  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 ( Attribute から継承されます。)
パブリック メソッド GetHashCode  このインスタンスのハッシュ コードを返します。 ( Attribute から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド IsDefaultAttribute  派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 ( Attribute から継承されます。)
パブリック メソッド IsDefined  オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 ( Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 ( Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

WebServiceAttribute クラス
System.Web.Services 名前空間
WebService クラス
WebMethodAttribute クラス
SoapDocumentMethodAttribute
SoapDocumentServiceAttribute
SoapRpcMethodAttribute
SoapRpcServiceAttribute

WebServiceAttribute メンバ

XML Web サービスに追加情報 (機能を説明する文字列など) を追加するために使用します。

WebServiceAttribute データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド WebServiceAttribute WebServiceAttribute クラスの新しいインスタンスを初期化します。
パブリック フィールドパブリック フィールド
  名前 説明
パブリック フィールド DefaultNamespace Namespace プロパティの既定値。このフィールドは定数です。
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Equals  オーバーロードされます。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttribute  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 (Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 (Attribute から継承されます。)
パブリック メソッド GetHashCode  このインスタンスのハッシュ コードを返します。 (Attribute から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド IsDefaultAttribute  派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 (Attribute から継承されます。)
パブリック メソッド IsDefined  オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 (Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

WebServiceAttribute クラス
System.Web.Services 名前空間
WebService クラス
WebMethodAttribute クラス
SoapDocumentMethodAttribute
SoapDocumentServiceAttribute
SoapRpcMethodAttribute
SoapRpcServiceAttribute



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「WebServiceAttribute」の関連用語

WebServiceAttributeのお隣キーワード
検索ランキング

   

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



WebServiceAttributeのページの著作権

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

©2026 GRAS Group, Inc.RSS