WebInvokeAttribute クラス

定義

サービス操作が論理的には呼び出し操作であり、WCF REST プログラミング モデルで呼び出すことができることを示す属性を表します。

public ref class WebInvokeAttribute sealed : Attribute, System::ServiceModel::Description::IOperationBehavior
[System.AttributeUsage(System.AttributeTargets.Method)]
public sealed class WebInvokeAttribute : Attribute, System.ServiceModel.Description.IOperationBehavior
[<System.AttributeUsage(System.AttributeTargets.Method)>]
type WebInvokeAttribute = class
    inherit Attribute
    interface IOperationBehavior
Public NotInheritable Class WebInvokeAttribute
Inherits Attribute
Implements IOperationBehavior
継承
WebInvokeAttribute
属性
実装

WebInvokeAttribute 属性を使用する方法を次のコード例に示します。

注意

Method プロパティは次のコードで指定されていないので、すべてのサービス操作は HTTP POST メソッドにマップされます。

[ServiceContract]
public interface ICalculator2
{
    [OperationContract]
    [WebInvoke]
    long Add(long x, long y);

    [OperationContract]
    [WebInvoke(UriTemplate = "Sub?x={x}&y={y}")]
    long Subtract(long x, long y);

    [OperationContract]
    [WebInvoke(UriTemplate = "Mult?x={x}&y={y}", BodyStyle = WebMessageBodyStyle.Bare)]
    long Multiply(long x, long y);

    [OperationContract]
    [WebInvoke(UriTemplate = "Div?x={x}&y={y}", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml, ResponseFormat=WebMessageFormat.Xml)]
    long Divide(long x, long y);

    [OperationContract]
    [WebInvoke(Method = "POST", UriTemplate = "Mod?x={x}&y={y}")]
    long Mod(long x, long y);
}
<ServiceContract()> _
Public Interface ICalculator2
    <OperationContract()> _
    <WebInvoke()> _
    Function Add(ByVal x As Long, ByVal y As Long) As Long

    <OperationContract()> _
    <WebInvoke(UriTemplate:="Sub?x={x}&y={y}")> _
    Function Subtract(ByVal x As Long, ByVal y As Long) As Long

    <OperationContract()> _
    <WebInvoke(UriTemplate:="Mult?x={x}&y={y}", BodyStyle:=WebMessageBodyStyle.Bare)> _
    Function Multiply(ByVal x As Long, ByVal y As Long) As Long

    <OperationContract()> _
    <WebInvoke(UriTemplate:="Div?x={x}&y={y}", BodyStyle:=WebMessageBodyStyle.Bare, RequestFormat:=WebMessageFormat.Xml, ResponseFormat:=WebMessageFormat.Xml)> _
    Function Divide(ByVal x As Long, ByVal y As Long) As Long

    <OperationContract()> _
   <WebInvoke(Method:="POST", UriTemplate:="Mod?x={x}&y={y}")> _
   Function Modulo(ByVal x As Long, ByVal y As Long) As Long
End Interface

注釈

WebInvokeAttribute 属性は、OperationContractAttribute に加えてサービス操作に適用され、呼び出しを表す、基になるトランスポートの動詞 (HTTP POST、PUT、DELETE など) と同様に、その操作を UriTemplate と関連付けます。 この属性はWebInvokeAttribute、操作の説明にメタデータをIOperationBehavior追加する パッシブ な操作動作 (メソッドは何もしません) です。 このメタデータを操作の説明で検索する動作 (WebInvokeAttribute など) がサービスの動作コレクションに追加されていない場合は、WebHttpBehavior 属性をサービス操作に適用しても機能しません。 WebInvokeAttribute は、サービス操作が応答する HTTP メソッドを定義します。 既定では、WebInvokeAttribute が適用されたすべてのメソッドは、POST 要求に応答します。 Method プロパティでは、異なる HTTP メソッドを指定できます。 GET に応答するサービス操作が必要な場合は、代わりに WebGetAttribute を使用します。

コンストラクター

WebInvokeAttribute()

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

プロパティ

BodyStyle

サービス操作との間で送受信されるメッセージの本文のスタイルを取得または設定します。

IsBodyStyleSetExplicitly

IsBodyStyleSetExplicitly プロパティを取得します。

IsRequestFormatSetExplicitly

IsRequestFormatSetExplicitly プロパティを取得します。

IsResponseFormatSetExplicitly

IsResponseFormatSetExplicitly プロパティを取得します。

Method

サービス操作が応答するプロトコル (HTTP など) のメソッドを取得または設定します。

RequestFormat

RequestFormat プロパティを取得または設定します。

ResponseFormat

ResponseFormat プロパティを取得または設定します。

TypeId

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

(継承元 Attribute)
UriTemplate

サービス操作の URI (Uniform Resource Identifier) テンプレート。

メソッド

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)
IOperationBehavior.AddBindingParameters(OperationDescription, BindingParameterCollection)

AddBindingParameters(OperationDescription, BindingParameterCollection) メソッドを実装します。

IOperationBehavior.ApplyClientBehavior(OperationDescription, ClientOperation)

ApplyClientBehavior(OperationDescription, ClientOperation) メソッドを実装します。

IOperationBehavior.ApplyDispatchBehavior(OperationDescription, DispatchOperation)

ApplyDispatchBehavior(OperationDescription, DispatchOperation) メソッドを実装します。

IOperationBehavior.Validate(OperationDescription)

Validate(OperationDescription) メソッドを実装します。

適用対象