Gav*_*ley 6 c# xml serialization
我在我的.net项目中添加了一个web ref,其中包含第三方服务的方法.
当我尝试调用其中一个方法时,它期望一个OrderIdentifier对象被传递,但是它给了我错误:
InvalidOperationException:<> f__AnonymousType0`3 [System.DateTime,ETS_OpenAccessNew.ETS.DateRange,ETS_OpenAccessNew.ETS.AuctionIdentification]无法序列化,因为它没有无参数构造函数.
我的代码如下:
OrderIdentifier oi = new OrderIdentifier
{
area = testArea,
portfolio = testPortfolio
};
DateRange dr = new DateRange { from = DateTime.Today.AddDays(-7), to = DateTime.Today };
var Ai = new AuctionIdentification
{
Item = DateTime.Today.AddDays(-1),
ItemElementName = ItemChoiceType1.AuctionDate,
name = "test",
duration = AuctionIdentificationDuration.Item30min,
durationSpecified = true
};
object items = new
{
deliveryDay = DateTime.Today.AddDays(-1),
deliveryDays = dr,
AuctionIdentification = Ai
};
oi.Items = new object[1] { items };
var orders = oa.RetrieveOrders(oi);
Run Code Online (Sandbox Code Playgroud)
引用的类如下:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.3130.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:openaccess")]
public partial class OrderIdentifier : IdentifiedOrder {
}
[System.Xml.Serialization.XmlIncludeAttribute(typeof(OrderIdentifier))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(Order))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ComplexOrderIdentification))]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.3130.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:openaccess")]
public partial class IdentifiedOrder : AbstractOrderObject {
private string areaField;
private string portfolioField;
private object[] itemsField;
/// <remarks/>
public string area {
get {
return this.areaField;
}
set {
this.areaField = value;
}
}
/// <remarks/>
public string portfolio {
get {
return this.portfolioField;
}
set {
this.portfolioField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("AuctionIdentification", typeof(AuctionIdentification))]
[System.Xml.Serialization.XmlElementAttribute("deliveryDay", typeof(System.DateTime), DataType="date")]
[System.Xml.Serialization.XmlElementAttribute("deliveryDays", typeof(DateRange))]
public object[] Items {
get {
return this.itemsField;
}
set {
this.itemsField = value;
}
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIncludeAttribute(typeof(Curve))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(IdentifiedOrder))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(OrderIdentifier))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(Order))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ComplexOrderIdentification))]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.3130.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:openaccess")]
public partial class AbstractOrderObject : OpenAccessAbstractObject {
}
/// <remarks/>
[System.Xml.Serialization.XmlIncludeAttribute(typeof(MarketResultIdentifier))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(Broadcast))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BlockOrderBatch))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AuctionInformationQuery))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AuctionDateTime))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AsynchronousResponseHeader))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AreaPortfolioInformationQuery))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(MessageAbstractObject))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(Messages))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(MessageIdentifier))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ClientMessage))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(MarketResult))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(HourlyOrderAbstractObject))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(HourlyOrderIdentification))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(HourlyPeriod))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(HourlyOrder))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CurvePoint))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AbstractOrderObject))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(Curve))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(IdentifiedOrder))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(OrderIdentifier))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(Order))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ComplexOrderIdentification))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ComplexOrder))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AuctionInformation))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AreaAuctionIdentification))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AreaPortfolioInformation))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AreaInformation))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AsynchronousNotification))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ExclusiveGroupIndexToIdMapping))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BlockIndexToIdMapping))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AuctionIdentification))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BlockOrderAbstractObject))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BlockOrderIdentifier))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BlockOrder))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BlockPeriod))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(SmartBlockOrderAbstractObject))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(SmartBlockOrder))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BlockOrderForBatch))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ErrorObject))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(Acknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(UserLogoutAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(SetNewPasswordAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(SetMessagesAsReadAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveTradeableAreaSetsAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveSmartBlockOrdersAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveOrdersAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveMessagesAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveMarketResultAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveHourlyOrdersAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveComplexOrdersAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveBlockOrdersAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveAuctionInformationAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveAreaPortfolioInformationAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveAreaInformationAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ReportRelayServerErrorResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ReportRelayErrorResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RemoveReverseConnectionResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RegisterUserOnServerResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RegisterForAsyncEventsResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ProcessAsynchronousNotificationResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(LogoutAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(GetNotificationsResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(EstablishSessionResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(EstablishReverseConnectionResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(EnterHourlyOrderAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(EnterOrderAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(EnterComplexOrderAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(EnterBlockOrderBatchAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(EnterBlockOrderAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(DeRegisterUserOnServerResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CancelHourlyOrderAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CancelOrderAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CancelComplexOrderAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CancelBlockOrderAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BroadcastAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AcceptNotificationResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrievePortfoliosAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveViewablePortfoliosAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveTradablePortfoliosAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveBlocksAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveGroupAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveExclusiveGroupAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveAreasAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveViewableAreasAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveTradableAreasAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CancelBlockAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CancelGroupAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CancelExclusiveGroupAcknowledgement))]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.3130.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:openaccess")]
public partial class OpenAccessAbstractObject : DomainObject {
public OpenAccessAbstractObject() { }
}
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ResponseLimitationHeader))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(OpenAccessAbstractObject))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(MarketResultIdentifier))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(Broadcast))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BlockOrderBatch))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AuctionInformationQuery))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AuctionDateTime))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AsynchronousResponseHeader))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AreaPortfolioInformationQuery))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(MessageAbstractObject))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(Messages))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(MessageIdentifier))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ClientMessage))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(MarketResult))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(HourlyOrderAbstractObject))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(HourlyOrderIdentification))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(HourlyPeriod))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(HourlyOrder))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CurvePoint))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AbstractOrderObject))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(Curve))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(IdentifiedOrder))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(OrderIdentifier))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(Order))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ComplexOrderIdentification))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ComplexOrder))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AuctionInformation))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AreaAuctionIdentification))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AreaPortfolioInformation))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AreaInformation))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AsynchronousNotification))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ExclusiveGroupIndexToIdMapping))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BlockIndexToIdMapping))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AuctionIdentification))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BlockOrderAbstractObject))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BlockOrderIdentifier))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BlockOrder))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BlockPeriod))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(SmartBlockOrderAbstractObject))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(SmartBlockOrder))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BlockOrderForBatch))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ErrorObject))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(Acknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(UserLogoutAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(SetNewPasswordAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(SetMessagesAsReadAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveTradeableAreaSetsAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveSmartBlockOrdersAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveOrdersAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveMessagesAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveMarketResultAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveHourlyOrdersAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveComplexOrdersAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveBlockOrdersAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveAuctionInformationAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveAreaPortfolioInformationAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveAreaInformationAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ReportRelayServerErrorResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ReportRelayErrorResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RemoveReverseConnectionResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RegisterUserOnServerResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RegisterForAsyncEventsResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ProcessAsynchronousNotificationResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(LogoutAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(GetNotificationsResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(EstablishSessionResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(EstablishReverseConnectionResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(EnterHourlyOrderAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(EnterOrderAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(EnterComplexOrderAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(EnterBlockOrderBatchAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(EnterBlockOrderAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(DeRegisterUserOnServerResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CancelHourlyOrderAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CancelOrderAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CancelComplexOrderAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CancelBlockOrderAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BroadcastAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AcceptNotificationResponse))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrievePortfoliosAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveViewablePortfoliosAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveTradablePortfoliosAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveBlocksAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveGroupAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveExclusiveGroupAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveAreasAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveViewableAreasAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RetrieveTradableAreasAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CancelBlockAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CancelGroupAcknowledgement))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CancelExclusiveGroupAcknowledgement))]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.3130.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:openaccess")]
public partial class DomainObject : System.Web.Services.Protocols.SoapHeader {
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.3130.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:openaccess")]
public partial class AuctionIdentification : OpenAccessAbstractObject {
public AuctionIdentification(){}
private System.DateTime itemField;
private ItemChoiceType1 itemElementNameField;
private string nameField;
private AuctionIdentificationDuration durationField;
private bool durationFieldSpecified;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("AuctionDate", typeof(System.DateTime), DataType="date")]
[System.Xml.Serialization.XmlElementAttribute("UTCDateTime", typeof(System.DateTime))]
[System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemElementName")]
public System.DateTime Item {
get {
return this.itemField;
}
set {
this.itemField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public ItemChoiceType1 ItemElementName {
get {
return this.itemElementNameField;
}
set {
this.itemElementNameField = value;
}
}
/// <remarks/>
public string name {
get {
return this.nameField;
}
set {
this.nameField = value;
}
}
/// <remarks/>
public AuctionIdentificationDuration duration {
get {
return this.durationField;
}
set {
this.durationField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool durationSpecified {
get {
return this.durationFieldSpecified;
}
set {
this.durationFieldSpecified = value;
}
}
}
//Retrieve Orders
[System.Web.Services.Protocols.SoapHeaderAttribute("SessionTokenValue")]
[System.Web.Services.Protocols.SoapHeaderAttribute("ResponseLimitationHeaderValue", Direction=System.Web.Services.Protocols.SoapHeaderDirection.InOut)]
[System.Web.Services.Protocols.SoapRpcMethodAttribute("RetrieveOrders", RequestNamespace="urn:openaccess", ResponseNamespace="urn:openaccess", Use=System.Web.Services.Description.SoapBindingUse.Literal)]
public RetrieveOrdersAcknowledgement RetrieveOrders(OrderIdentifier OrderIdentifier) {
object[] results = this.Invoke("RetrieveOrders", new object[] {
OrderIdentifier});
return ((RetrieveOrdersAcknowledgement)(results[0]));
}
Run Code Online (Sandbox Code Playgroud)
关于我在这里做错的任何想法都会非常感激
更新 - 我现在已将无参数构造函数包含在AuctionIdentification类中,但仍会收到相同的错误
异常的消息告诉你,你正在试图序列匿名类型包含DateTime,DateRange以及AuctionIdentification性能和匿名类型的确没有参数构造函数(它们是不变的,所以他们的成员是通过构造函数的参数初始化).
创建有问题的匿名类型并将其分配给items变量:
object items = new // <--
{
deliveryDay = DateTime.Today.AddDays(-1),
deliveryDays = dr,
AuctionIdentification = Ai
};
oi.Items = new object[1] { items };
Run Code Online (Sandbox Code Playgroud)
根据Items属性定义
[System.Xml.Serialization.XmlElementAttribute("AuctionIdentification", typeof(AuctionIdentification))]
[System.Xml.Serialization.XmlElementAttribute("deliveryDay", typeof(System.DateTime), DataType="date")]
[System.Xml.Serialization.XmlElementAttribute("deliveryDays", typeof(DateRange))]
public object[] Items {
get {
return this.itemsField;
}
set {
this.itemsField = value;
}
}
Run Code Online (Sandbox Code Playgroud)
它的阵列objects,其中每个的实际类型object可以是所描述的3种类型中的一个- DateTime,DateRange和AuctionIdentification.
有点奇怪的设计,但这是第三方服务的错,而不是你的.在你的情况下正确的初始化(也应该修复有问题的异常)应该是直接填充数组:
oi.Items = new object[] // <--
{
DateTime.Today.AddDays(-1), // deliveryDay
dr, // deliveryDays
Ai // AuctionIdentification
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
159 次 |
| 最近记录: |