WebServiceAttribute クラス

定義

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

public ref class WebServiceAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class)]
public sealed class WebServiceAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface)]
public sealed class WebServiceAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class)>]
type WebServiceAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface)>]
type WebServiceAttribute = class
    inherit Attribute
Public NotInheritable Class WebServiceAttribute
Inherits Attribute
継承
WebServiceAttribute
属性

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

<%@ 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;
    }   
 }
<%@ 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

注釈

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

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

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

属性の使用の詳細については、「 属性」を参照してください。

コンストラクター

WebServiceAttribute()

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

フィールド

DefaultNamespace

Namespace プロパティの既定値。 このフィールドは定数です。

プロパティ

Description

XML Web サービスの説明メッセージ。

Name

XML Web サービスの名前を取得または設定します。

Namespace

XML Web サービスで使用する既定の XML 名前空間を取得または設定します。

TypeId

派生クラスで実装されると、この Attribute の一意の識別子を取得します。

(継承元 Attribute)

メソッド

Equals(Object)

このインスタンスが、指定されたオブジェクトと等価であるかどうかを示す値を返します。

(継承元 Attribute)
GetHashCode()

このインスタンスのハッシュ コードを返します。

(継承元 Attribute)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IsDefaultAttribute()

派生クラスでオーバーライドされるとき、このインスタンスの値が派生クラスの既定値であるかどうかを示します。

(継承元 Attribute)
Match(Object)

派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。

(継承元 Attribute)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

オブジェクトの型情報を取得します。この情報はインターフェイスの型情報の取得に使用できます。

(継承元 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。

(継承元 Attribute)

適用対象

こちらもご覧ください