MessageContractMemberAttribute.Namespace 屬性


指定對應於這個成員的項目命名空間。Specifies the namespace of the element that corresponds to this member.

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



對應於這個成員的項目命名空間 URI。A namespace URI of the element that corresponds to this member.


下列程式碼範例會示範自訂訊息合約,這個合約會使用 MessageContractAttributeMessageHeaderAttributeMessageBodyMemberAttribute 屬性 (其全都繼承自 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 訊息本文項目的成員:sourceAccounttargetAccount 以及 amount 值 (序列化成名稱為 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  
  [MessageHeader] public Operation operation;  
  [MessageHeader(Namespace="")] public bool IsAudited;  
  [MessageBody] public Account sourceAccount;  
  [MessageBody] public Account targetAccount;  
  [MessageBody(Name="transactionAmount")] public int amount;