HttpRequestMessageProperty クラス

定義

HTTP プロトコル経由の要求に利用できる追加情報にアクセスおよび応答するために、HTTP 要求へのアクセスを提供します。

public ref class HttpRequestMessageProperty sealed : System::ServiceModel::Channels::IMessageProperty
public ref class HttpRequestMessageProperty sealed
public sealed class HttpRequestMessageProperty : System.ServiceModel.Channels.IMessageProperty
public sealed class HttpRequestMessageProperty
type HttpRequestMessageProperty = class
    interface IMessageProperty
type HttpRequestMessageProperty = class
Public NotInheritable Class HttpRequestMessageProperty
Implements IMessageProperty
Public NotInheritable Class HttpRequestMessageProperty
継承
HttpRequestMessageProperty
実装

次のコードでは、このクラスのインスタンスでいくつかのプロパティを設定し、そのインスタンスをメッセージに組み込む方法を示します。

static Message BuildMessage()
{
    Message messageToSend = null;
    HttpRequestMessageProperty reqProps = new HttpRequestMessageProperty();
    reqProps.SuppressEntityBody = false;
    reqProps.Headers.Add("CustomHeader", "Test Value");
    reqProps.Headers.Add(HttpRequestHeader.UserAgent, "my user agent");

    try
    {
        messageToSend = Message.CreateMessage(MessageVersion.Soap11, "http://tempuri.org/IUntypedService/ProcessMessage", "Hello WCF");
    }
    catch (Exception e)
    {
        Console.WriteLine("got exception when sending message: " + e.ToString());
    }

    messageToSend.Properties[HttpRequestMessageProperty.Name] = reqProps;
    return messageToSend;
}
Private Shared Function BuildMessage() As Message
    Dim messageToSend As Message = Nothing
    Dim reqProps As New HttpRequestMessageProperty()
    reqProps.SuppressEntityBody = False
    reqProps.Headers.Add("CustomHeader", "Test Value")
    reqProps.Headers.Add(HttpRequestHeader.UserAgent, "my user agent")

    Try
        messageToSend = Message.CreateMessage(MessageVersion.Soap11, "http://tempuri.org/IUntypedService/ProcessMessage", "Hello WCF")
    Catch e As Exception
        Console.WriteLine("got exception when sending message: " & e.ToString())
    End Try

    messageToSend.Properties(HttpRequestMessageProperty.Name) = reqProps
    Return messageToSend
End Function

注釈

これは開発者が HTTP 要求の情報に直接アクセスできるようにする汎用クラスであり、HTTP 固有の情報をカプセル化するために使用できます。 一例として、このクラスは、Representational State Transfer (REST) アーキテクチャに従って実装されたサービスをサポートするために使用できます。

このクラスを使用すると、以下のシナリオをサポートできます。

  • 要求ごとに使用する HTTP 動詞を変更する。

  • 要求によって HTTP ヘッダー (キー、値) ペアを設定および照会できるようにする。

  • HTTP 要求に対してクエリ文字列を指定できるようにする。

このクラスを、HttpTransportBindingElement および関連クラスによって使用できます。

受信メッセージの場合、このプロパティはメッセージに追加されます。

送信メッセージの場合、このプロパティにより以下の処理が行われます。

  • MethodMethod に設定されます。

  • QueryStringRequestUri の末尾に追加されます。

  • Headers は、送信されるように設定された HTTP ヘッダーに追加されます。

コンストラクター

HttpRequestMessageProperty()

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

プロパティ

Headers

HTTP 要求から HTTP ヘッダーを取得します。

HttpRequestMessage

HTTP プロトコル経由の要求に利用できる追加情報にアクセスおよび応答するために、HTTP 要求へのアクセスを提供します。

Method

HTTP 要求の HTTP 動詞を取得または設定します。

Name

HttpRequestMessageProperty クラスに関連付けられているメッセージ プロパティの名前を取得します。

QueryString

HTTP 要求に対するクエリ文字列を取得または設定します。

SuppressEntityBody

メッセージの本文を無視してヘッダーのみを送信するかどうかを示す値を取得または設定します。

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

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

(継承元 Object)
MemberwiseClone()

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

(継承元 Object)
ToString()

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

(継承元 Object)

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

IMessageProperty.CreateCopy()

現在のオブジェクトのコピーを作成して返します。

適用対象