我的服务适用于其他方法,但是当我尝试使用更复杂的集合调用方法时出现错误(来自 Service Trace Viewer)
'尝试序列化参数http://tempuri.org/:GetDataEventSetResult时出错。InnerException 消息是 'Type 'MimosaServerLib.DAInt' 与数据合同名称 'DAInt: http://schemas.datacontract.org/2004/07/MimosaServerLib ' 不是预期的......'
对我看到的具有相同错误的问题的答案涉及更改类定义以关闭“ProxyCreationEnabled”,但我正在使用的类(DataEventSet
,DAInt
)来自使用我一直使用的 xsd 工具自动生成的文件给定的。即我不应该改变它。
我创建了DataEventSet
暴露的对象,如下所示:
private DataEventSet CreateDataEventSet()
{
DataEventSet aDataEventSet = new DataEventSet();
DataEvent[] dataEvents = new DataEvent[2];
DAInt aDAInt = new DAInt();
aDAInt.id = 100100100;
aDAInt.value = 1;
dataEvents[0] = aDAInt;
DADataSeq aDADataSeq = new DADataSeq();
aDADataSeq.id = 200100100;
double[] vals = new double[2];
vals[0] = 5;
vals[1] = 44;
aDADataSeq.values = vals;
double[] vals2 = new double[2];
vals2[0] = 1;
vals2[1] = 1;
aDADataSeq.xAxisDeltas = vals2;
aDADataSeq.xAxisStart = 0;
dataEvents[1] = aDADataSeq;
aDataEventSet.id = 0;
Site aSite = new Site();
aSite.category = SITE_CATEGORY.SITE_SPECIFIC;
aDataEventSet.site = aSite;
OsacbmTime aTime = new OsacbmTime();
aTime.tick_time = 12313246;
aTime.time = "2007-09-20T14:46:04.123";
aTime.time_type = OsacbmTimeType.OSACBM_TIME_MIMOSA;
aDataEventSet.time = aTime;
aDataEventSet.dataEvents = dataEvents;
return aDataEventSet;
}
编辑:的类定义DataEventSet
//This source code was auto-generated by xsd
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.mimosa.org/OSACBMV3-1l")]
[System.Xml.Serialization.XmlRootAttribute(Namespace="http://www.mimosa.org/OSACBMV3-1l", IsNullable=false)]
public partial class DataEventSet {
private bool alertStatusField;
private bool alertStatusFieldSpecified;
private DataEvent[] dataEventsField;
private ulong idField;
private Site siteField;
private OsacbmTime timeField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public bool alertStatus {
get {
return this.alertStatusField;
}
set {
this.alertStatusField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool alertStatusSpecified {
get {
return this.alertStatusFieldSpecified;
}
set {
this.alertStatusFieldSpecified = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("dataEvents", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public DataEvent[] dataEvents {
get {
return this.dataEventsField;
}
set {
this.dataEventsField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public ulong id {
get {
return this.idField;
}
set {
this.idField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public Site site {
get {
return this.siteField;
}
set {
this.siteField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public OsacbmTime time {
get {
return this.timeField;
}
set {
this.timeField = value;
}
}
}