MessageContractMemberAttribute.Namespace 屬性

定義

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

public:
 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

屬性值

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 標頭項目位於 http://schemas.contosobank.com/auditing/2005 命名空間中,而 sourceAccount 已經過加密和數位簽署。In addition, the IsAudited SOAP header element resides in the http://schemas.contosobank.com/auditing/2005 namespace, and sourceAccount is encrypted and digitally signed.

注意

OperationAccount 型別必須具有資料合約。The Operation and Account types must have a data contract.

[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;  

適用於