Compartir a través de


HttpRequestMessageProperty Constructor

Definición

Inicializa una nueva instancia de la clase HttpRequestMessageProperty.

public:
 HttpRequestMessageProperty();
public HttpRequestMessageProperty ();
Public Sub New ()

Ejemplos

El código siguiente muestra cómo crear instancias de esta clase a partir de un mensaje sin llamar explícitamente al constructor.

public void ProcessMessage(Message input)
{
    try
    {
        Console.WriteLine("ProcessMessage: Message received: " + input.GetBody<string>());
        HttpRequestMessageProperty reqProp = (HttpRequestMessageProperty)input.Properties[HttpRequestMessageProperty.Name];
        string customString = reqProp.Headers.Get("CustomHeader");
        string userAgent = reqProp.Headers[HttpRequestHeader.UserAgent];
        Console.WriteLine();
        Console.WriteLine("ProcessMessage: Got custom header: {0}, User-Agent: {1}", customString, userAgent);
    }
    catch (Exception e)
    {
        Console.WriteLine("ProcessMessage: got exception: " + e.ToString());
    }
}
Public Sub ProcessMessage(ByVal input As Message) Implements IUntypedService.ProcessMessage
    Try
        Console.WriteLine("ProcessMessage: Message received: " & input.GetBody(Of String)())
        Dim reqProp = CType(input.Properties(HttpRequestMessageProperty.Name), HttpRequestMessageProperty)
        Dim customString = reqProp.Headers.Get("CustomHeader")
        Dim userAgent = reqProp.Headers(HttpRequestHeader.UserAgent)
        Console.WriteLine()
        Console.WriteLine("ProcessMessage: Got custom header: {0}, User-Agent: {1}", customString, userAgent)
    Catch e As Exception
        Console.WriteLine("ProcessMessage: got exception: " & e.ToString())
    End Try
End Sub

Comentarios

Este constructor inicializa el objeto de la manera siguiente:

Se aplica a