MessageDescription Classe

Definição

Representa a descrição de uma mensagem.Represents the description of a message.

public ref class MessageDescription
public class MessageDescription
type MessageDescription = class
Public Class MessageDescription
Herança
MessageDescription

Exemplos

O exemplo a seguir usa a MessageDescription propriedade retornada da Messages OperationDescription classe.The following example uses the MessageDescription returned from Messages property of the OperationDescription class. O código faz a iteração pela coleção de pontos de extremidade e imprime cada nome de EndPoint, bem como o nome de cada operação no ponto de extremidade.The code iterates through the collection of endpoints and prints each endpoint name, as well as the name of each operation in the endpoint.

private void PrintDescription(ServiceHost sh)
{
    // Declare variables.
    int i, j, k, l, c;
    ServiceDescription servDesc = sh.Description;
    OperationDescription opDesc;
    ContractDescription contractDesc;
    MessageDescription methDesc;
    MessageBodyDescription mBodyDesc;
    MessagePartDescription partDesc;
    IServiceBehavior servBeh;
    ServiceEndpoint servEP;

    // Print the behaviors of the service.
    Console.WriteLine("Behaviors:");
    for (c = 0; c < servDesc.Behaviors.Count; c++)
    {
        servBeh = servDesc.Behaviors[c];
        Console.WriteLine("\t{0}", servBeh.ToString());
    }

    // Print the endpoint descriptions of the service.
    Console.WriteLine("Endpoints");
    for (i = 0; i < servDesc.Endpoints.Count; i++)
    {
        // Print the endpoint names.
        servEP = servDesc.Endpoints[i];
        Console.WriteLine("\tName: {0}", servEP.Name);
        contractDesc = servEP.Contract;

        Console.WriteLine("\tOperations:");
        for (j = 0; j < contractDesc.Operations.Count; j++)
        {
            // Print the operation names.
            opDesc = servEP.Contract.Operations[j];
            Console.WriteLine("\t\t{0}", opDesc.Name);
            Console.WriteLine("\t\tActions:");
            for (k  = 0; k < opDesc.Messages.Count; k++)
            {
                // Print the message action.
                methDesc = opDesc.Messages[k];
                Console.WriteLine("\t\t\tAction:{0}", methDesc.Action);

                // Check for the existence of a body, then the body description.
                mBodyDesc = methDesc.Body;
                if (mBodyDesc.Parts.Count > 0)
                {
                    for (l = 0; l < methDesc.Body.Parts.Count; l++)
                    {
                        partDesc = methDesc.Body.Parts[l];
                        Console.WriteLine("\t\t\t\t{0}",partDesc.Name);
                    }
                }
            }
        }
    }
}
Private Sub PrintDescription(ByVal sh As ServiceHost) 
    ' Declare variables.
    Dim i, j, k, l, c As Integer
    Dim servDesc As ServiceDescription = sh.Description
    Dim opDesc As OperationDescription
    Dim contractDesc As ContractDescription
    Dim methDesc As MessageDescription
    Dim mBodyDesc As MessageBodyDescription
    Dim partDesc As MessagePartDescription
    Dim servBeh As IServiceBehavior
    Dim servEP As ServiceEndpoint
    
    ' Print the behaviors of the service.
    Console.WriteLine("Behaviors:")
    For c = 0 To servDesc.Behaviors.Count-1
        servBeh = servDesc.Behaviors(c)
        Console.WriteLine(vbTab + "{0}", servBeh)
    Next c
    
    ' Print the endpoint descriptions of the service.
    Console.WriteLine("Endpoints")
    For i = 0 To servDesc.Endpoints.Count-1
        ' Print the endpoint names.
        servEP = servDesc.Endpoints(i)
        Console.WriteLine(vbTab + "Name: {0}", servEP.Name)
        contractDesc = servEP.Contract
        
        Console.WriteLine(vbTab + "Operations:")
        For j = 0 To contractDesc.Operations.Count-1
            ' Print operation names.
            opDesc = servEP.Contract.Operations(j)
            Console.WriteLine(vbTab + vbTab + "{0}", opDesc.Name)
            Console.WriteLine(vbTab + vbTab + "Actions:")
            For k = 0 To opDesc.Messages.Count-1
                ' Print the message action. 
                methDesc = opDesc.Messages(k)
                Console.WriteLine(vbTab + vbTab + vbTab + _
                  "Action:{0}", methDesc.Action)
                
                ' Check for the existence of a body, then the body description.
                mBodyDesc = methDesc.Body
                If mBodyDesc.Parts.Count > 0 Then
                    For l = 0 To methDesc.Body.Parts.Count-1
                        partDesc = methDesc.Body.Parts(l)
                        Console.WriteLine(vbTab + vbTab + _
                        vbTab + vbTab + "{0}", partDesc.Name)
                    Next l
                End If
            Next k
        Next j
    Next i

End Sub     

Comentários

O MessageDescription contém as Headers Body Propriedades e para fornecer acesso a essas partes da mensagem.The MessageDescription contains the Headers and Body properties to provide get access to these parts of the message. Se a mensagem é de entrada ou de saída é indicada pela Direction propriedade.Whether the message is incoming or outgoing is indicated by the Direction property. Ele também fornece uma Action propriedade em que o URI que indica a intenção da mensagem pode ser especificado.It also provides an Action property where the URI that indicates the intention of the message may be specified.

Construtores

MessageDescription(String, MessageDirection)

Inicializa uma nova instância da classe MessageDescription com uma ação e uma direção especificadas.Initializes a new instance of the MessageDescription class with a specified action and direction.

Propriedades

Action

Obtém ou define o parâmetro de ação da mensagem SOAP que identifica a intenção da mensagem.Gets or sets the action parameter of the SOAP message that identifies the intent of the message.

Body

Obtém o corpo da mensagem SOAP.Gets the body of the SOAP message.

Direction

Obtém a direção que indica se a mensagem está entrando ou saindo.Gets the direction that indicates whether the message is incoming or outgoing.

HasProtectionLevel

Obtém um valor que indica se o ProtectionLevel foi definido.Gets a value that indicates whether the ProtectionLevel has been set.

Headers

Obtém a descrição dos cabeçalhos da mensagem SOAP.Gets the description of the headers of the SOAP message.

MessageType

Obtém ou define um tipo que identifica o tipo de contrato de mensagem.Gets or sets a type that identifies the type of message contract.

Properties

Obtém uma descrição das propriedades da mensagem SOAP.Gets a description of the properties of the SOAP message.

ProtectionLevel

Obtém ou define os serviços de segurança necessários para a mensagem.Gets or sets the security services required for the message.

Métodos

Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object.

(Herdado de Object)
GetHashCode()

Serve como a função de hash padrão.Serves as the default hash function.

(Herdado de Object)
GetType()

Obtém o Type da instância atual.Gets the Type of the current instance.

(Herdado de Object)
MemberwiseClone()

Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object.

(Herdado de Object)
ShouldSerializeProtectionLevel()

Retorna um valor que indica se a propriedade ProtectionLevel foi alterada do valor padrão e se deve ser serializada.Returns a value that indicates whether the ProtectionLevel property has changed from its default value and should be serialized.

ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object.

(Herdado de Object)

Aplica-se a