MessageContractMemberAttribute.Name 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
指定對應該成員的元素名稱。
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 元素名稱。
範例
以下程式碼範例展示了一種自訂訊息合約,利用 MessageContractAttribute、 MessageHeaderAttribute和 MessageBodyMemberAttribute 屬性來建立自訂且強型別的訊息作為參數。 在此情況下,有三個資料成員被序列化為 SOAP 訊息的主體元素: sourceAccount、、 targetAccount以及 amount 值(序列化為名為 transactionAmount的元素)。 此外, IsAudited SOAP 標頭元素也位於 http://schemas.contosobank.com/auditing/2005 命名空間中。
Note
Operation這些類型Account也必須有資料合約。
[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;