Hizmetim diğer yöntemler için çalışıyor ancak daha karmaşık bir koleksiyona sahip bir yöntemi çağırmaya çalıştığımda hatadan (Hizmet İzleyicisi Görüntüleyicisi)WCF hatası 'Parametre serileştirilmeye çalışılırken bir hata oluştu ...'
'http://tempuri.org/:GetDataEventSetResult parametresini seri hale getirmeye çalışırken bir hata oluştu. InnerException iletisinin veri sözleşmesi adı olan 'Type' MimosaServerLib.DAInt 'idi' DAInt: http://schemas.datacontract.org/2004/07/MimosaServerLib 'beklenmiyor ...'
Aynı hataya sahip soruların cevapları, sınıf tanımını değiştirmek için değiştirmeyi de içeriyor. off 'ProxyCreationEnabled' ile çalıştığım sınıflar (DataEventSet
, DAInt
), verilmiş xsd aracı kullanılarak otomatik olarak oluşturulan bir dosyadan geliyor. yani onu değiştirmemeliydim.
DataEventSet
nesne oluşturmak:
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;
}
Edit: 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;
}
}
}
Teşekkürler! Şimdi WCF Test Client'ta çalışıyor. Ancak, bir dış İstemci ile hizmete erişmeye çalıştığımda, bir 'NetDispatcherFaultException' alıyorum: "http://tempuri.org/:GetDataEventSetResult. InnerException iletisi, 'Satır 1 konumunda 898 hatasıydı. Öğe' http: // şemaları .datacontract.org/2004/07/MimosaServerLib: DataEvent ', adıyla eşleşen bir türden veri içerir. " – Jimmy
Çözüldü: Servis referansını güncellemek için gerekli lol. – Jimmy
KnownType() özniteliği mi kullanıyordu? –