我有我想添加額外屬性的WSDL服務類。當我試圖反序列化我的派生類時,它給出錯誤「您需要將XmlChoiceIdentifierAttribute添加到'ObjCreatePaperClipTransaction'成員。」使用XmlChoiceIdentifierAttribute序列化派生類成員
這是我在服務類上寫的代碼。 (executeCreatePaperClipTransaction
& CreatePaperClipTransactionType
是從代理對象類)
namespace MyProject.DTO
{
[XmlType("executeCreatePaperClipTransaction")]
public partial class CustomExecuteCreatePaperClipTransaction : executeCreatePaperClipTransaction
{
[XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 0)]
[XmlElement("CreatePaperClipTransaction")]
public CustomCreatePaperClipTransactionType ObjCreatePaperClipTransaction { get; set; }
}
public partial class CustomCreatePaperClipTransactionType : CreatePaperClipTransactionType
{
[XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 0)]
public executeCreateLoanIncrease ObjLoanIncreaseRequest { get; set; }
[XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 1)]
public executeCreateFreeFormEventFeePayment ObjFreeFormEventFeePaymentRequest { get; set; }
}
}
當我刪除[XmlElement("CreatePaperClipTransaction")]
線,其工作的罰款。但在seralized XML我想標籤名稱是CreatePaperClipTransaction
而不是ObjCreatePaperClipTransaction
我通過這個答案去了,但我不知道我怎麼能在我的情況下實現https://stackoverflow.com/a/20379038/1169180
爲什麼你有兩個'[XmlElement]'屬性附加到'ObjCreatePaperClipTransaction'屬性?你的問題是XML中可能有兩個不同的元素名稱,即和'',並且你想將它們綁定到ObjCreatePaperClipTransaction屬性?此外,由於缺少基本類型,您的代碼無法編譯。你可以添加它們以及要反序列化的XML樣本,因此將你的問題擴展到[mcve]? –
dbc