MessageContractMemberAttribute.Name 属性

定义

指定与此成员对应的元素的名称。

public:
 property System::String ^ Name { System::String ^ get(); void set(System::String ^ value); };
public string Name { get; set; }
member this.Name : string with get, set
Public Property Name As String

属性值

与此成员对应的元素的名称。 此字符串必须是有效的 XML 元素名称。

示例

下面的代码示例演示了一个自定义消息协定,该协定使用MessageContractAttributeMessageHeaderAttributeMessageBodyMemberAttribute属性创建自定义的强类型消息以用作参数。 在这种情况下,有三个数据成员序列化为 SOAP 消息的正文元素: sourceAccounttargetAccount以及 amount 值(它被序列化为具有名称 transactionAmount的元素)。 此外, IsAudited SOAP 标头元素位于命名空间中 http://schemas.contosobank.com/auditing/2005

注释

并且OperationAccount类型还必须具有数据协定。

[MessageContract]
public class BankingTransaction
{
  [MessageHeader] public Operation operation;
  [MessageHeader(Namespace="http://schemas.contosobank.com/auditing/2005")] public bool IsAudited;
  [MessageBody] public Account sourceAccount;
  [MessageBody] public Account targetAccount;
  [MessageBody(Name="transactionAmount")] public int amount;

适用于