MessageContractMemberAttribute MessageContractMemberAttribute MessageContractMemberAttribute MessageContractMemberAttribute Class


声明 MessageBodyMemberAttributeMessageHeaderAttribute 的基成员。Declares the base members for MessageBodyMemberAttribute and MessageHeaderAttribute.

public ref class MessageContractMemberAttribute abstract : Attribute
public abstract class MessageContractMemberAttribute : Attribute
type MessageContractMemberAttribute = class
    inherit Attribute
Public MustInherit Class MessageContractMemberAttribute
Inherits Attribute


下面的代码示例演示一个自定义消息协定, 该MessageContractAttribute协定MessageHeaderAttribute使用、 MessageBodyMemberAttribute和特性 (它们都从MessageContractMemberAttribute继承) 来创建要在操作中使用的自定义类型消息。The following code examples demonstrate a custom message contract that uses the MessageContractAttribute, MessageHeaderAttribute, and MessageBodyMemberAttribute attributes (which all inherit from MessageContractMemberAttribute) to create custom typed messages to use in operations. 在这种情况下,将有三个成员序列化到 SOAP 消息的正文元素中:sourceAccounttargetAccountamount 值(该值使用名称 transactionAmount 序列化到元素中)。In this case, there are three members that are serialized into the body element of the SOAP message: sourceAccount, targetAccount, and the amount value, (which is serialized into an element with the name transactionAmount). 此外,IsAudited SOAP 标头元素驻留在 命名空间中,而且还对 sourceAccount 进行加密和数字签名。In addition, the IsAudited SOAP header element resides in the namespace, and sourceAccount is encrypted and digitally signed.


OperationAccount 类型必须具有数据协定。The Operation and Account types must have a data contract.

public class BankingTransaction  
  public Operation operation;  
  public bool IsAudited;  
  public Account sourceAccount;  
  public Account targetAccount;  
  public int amount;  


此类包含对于 SOAP 消息的各部分都通用的属性。This class contains properties common to all parts of a SOAP message. 例如,所有部分都具有名称和命名空间,而且还可能应用了安全性级别。For example, all parts have a name and a namespace, and potentially a level of security applied.

有关在不修改默认 soap 信封本身的情况下控制 SOAP 正文内容序列化的信息, 请参阅System.Runtime.Serialization.DataContractAttribute在服务协定中指定数据传输使用数据协定For information on controlling the serialization of the contents of a SOAP body without modifying the default SOAP envelope itself, see System.Runtime.Serialization.DataContractAttribute, Specifying Data Transfer in Service Contracts, and Using Data Contracts.

有关创建消息协定的详细信息, 请参阅使用消息协定For more information about creating message contracts, see Using Message Contracts.


MessageContractMemberAttribute() MessageContractMemberAttribute() MessageContractMemberAttribute() MessageContractMemberAttribute()

初始化 MessageContractMemberAttribute 类的新实例。Initializes a new instance of the MessageContractMemberAttribute class.


HasProtectionLevel HasProtectionLevel HasProtectionLevel HasProtectionLevel

当在派生类中重写时,获取一个指示成员是否具有分配的保护级别的值。When overridden in a derived class, gets a value that indicates whether the member has a protection level assigned.

Name Name Name Name

指定与此成员对应的元素的名称。Specifies the name of the element that corresponds to this member.

Namespace Namespace Namespace Namespace

指定与此成员对应的元素的命名空间。Specifies the namespace of the element that corresponds to this member.

ProtectionLevel ProtectionLevel ProtectionLevel ProtectionLevel

指定该成员是否按原样传输,是否已签名或是否已签名和加密。Specifies whether the member is to be transmitted as-is, signed, or signed and encrypted.

TypeId TypeId TypeId TypeId

在派生类中实现时,获取此 Attribute 的唯一标识符。When implemented in a derived class, gets a unique identifier for this Attribute.

(Inherited from Attribute)


Equals(Object) Equals(Object) Equals(Object) Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。Returns a value that indicates whether this instance is equal to a specified object.

(Inherited from Attribute)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

(Inherited from Attribute)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否是派生类的默认值。When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(Inherited from Attribute)
Match(Object) Match(Object) Match(Object) Match(Object)

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(Inherited from Attribute)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)


_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。Maps a set of names to a corresponding set of dispatch identifiers.

(Inherited from Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。Retrieves the type information for an object, which can be used to get the type information for an interface.

(Inherited from Attribute)
_Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Inherited from Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。Provides access to properties and methods exposed by an object.

(Inherited from Attribute)