MessagePartDescription 类

定义

表示 SOAP 消息部分的说明。

public ref class MessagePartDescription
public class MessagePartDescription
type MessagePartDescription = class
Public Class MessagePartDescription
继承
MessagePartDescription
派生

示例

下面的示例使用了 MessagePartDescription 类的 Parts 属性返回的 MessageBodyDescription。 该代码循环访问终结点集合,并输出每个终结点的名称以及终结点中的每个操作的名称。

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

注解

MessagePartDescription 类是 MessageHeaderDescriptionMessagePropertyDescription 的父类,包含有这两个类的基本功能。

构造函数

MessagePartDescription(String, String)

初始化 MessagePartDescription 类的新实例。

属性

HasProtectionLevel

获取指示消息部分是否有 ProtectionLevel 属性的值的值。

Index

获取或设置消息部分的索引。

MemberInfo

获取或设置消息部分的成员信息。

Multiple

获取或设置控制消息部分是否可在消息中出现多次的值。

Name

获取或设置消息部分的名称。

Namespace

获取或设置消息部分的命名空间。

ProtectionLevel

获取或设置消息部分的 ProtectionLevel

Type

获取或设置消息部分的类型。

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于