MessageDescription 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示消息的说明。
public ref class MessageDescription
public class MessageDescription
type MessageDescription = class
Public Class MessageDescription
- 继承
-
MessageDescription
示例
下面的示例使用了从 MessageDescription 类的 Messages 属性返回的 OperationDescription。 该代码循环访问终结点集合,并输出每个终结点的名称以及终结点中的每个操作的名称。
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
注解
MessageDescription 包含 Headers 和 Body 属性,可提供对这些消息部分的访问。 Direction 属性可指示此消息是传入消息还是传出消息。 它还提供一个 Action 属性,其中 URI 指示可以指定消息的意图。
构造函数
MessageDescription(String, MessageDirection) |
用指定的操作和方向初始化 MessageDescription 类的新实例。 |
属性
Action |
获取或设置标识消息意图的 SOAP 消息的操作参数。 |
Body |
获取 SOAP 消息的正文。 |
Direction |
获取指示消息是传入消息还是传出消息的方向。 |
HasProtectionLevel |
获取一个指示 ProtectionLevel 是否已设置的值。 |
Headers |
获取 SOAP 消息的标头的说明。 |
MessageType |
获取或设置标识消息协定类型的类型。 |
Properties |
获取 SOAP 消息属性的说明。 |
ProtectionLevel |
获取或设置消息所需的安全服务。 |
方法
Equals(Object) |
确定指定对象是否等于当前对象。 (继承自 Object) |
GetHashCode() |
作为默认哈希函数。 (继承自 Object) |
GetType() |
获取当前实例的 Type。 (继承自 Object) |
MemberwiseClone() |
创建当前 Object 的浅表副本。 (继承自 Object) |
ShouldSerializeProtectionLevel() |
返回一个值,该值指示 ProtectionLevel 属性是否已更改,不再是默认值且应对其进行序列化。 |
ToString() |
返回表示当前对象的字符串。 (继承自 Object) |