Ich entwickle (neu schreiben auf WCF) eine Datei Parsen Web-Service zu akzeptieren string[]
und Rückkehr ISection[]
aber eigentlich ist das eine Reihe von verschachtelten Schnittstellen erben:Daten Kontrakt Bekannte Typen und eine Reihe von Schnittstellen miteinander
namespace Project.Contracts // Project.Contracts.dll
{
public interface ISection { }
public interface ISummarySection : ISection { }
public interface IDataSection : ISection { }
}
und Klassen:
namespace Project.Format.A // Project.Format.A.dll
{
[DataContract]
public class SummarySectionFormatA : ISummarySection { }
[DataContract]
public class DataSectionFormatA : IDataSection { }
}
Service-Schnittstelle und deren Umsetzung:
[ServiceContract]
public interface IService // Project.Contracts.dll
{
ISection[] Parse(string format, string[] data);
}
[ServiceKnownType(typeof(SummarySectionFormatA))] // tried this also
[ServiceKnownType(typeof(DataSectionFormatA))]
public class Service : IService // Project.Service.dll
{
public ISection[] Parse(string format, string[] data)
{
return Factory.Create(format).Parse(data);
}
}
Ich versuchte declaredTypes
auf beide Server und Clients zu konfigurieren:
<system.runtime.serialization>
<dataContractSerializer>
<declaredTypes>
<add type="Project.Contracts.ISumarySection, Project.Contracts">
<knownType type="Project.Format.A.SummarySectionFormatA, Project.Format.A" />
</add>
<add type="Project.Contracts.IDataSection, Project.Contracts">
<knownType type="Project.Format.A.DataSectionFormatA, Project.Format.A" />
</add>
</declaredTypes>
</dataContractSerializer>
</system.runtime.serialization>
aber immer noch die gleiche Fehlermeldung erhalten:
"Type 'DataSectionFormatA' with data contract name 'DataSection:http://schemas.example.com/Parse' is not expected.
oder
The underlying connection was closed: The connection was closed unexpectedly.
ich dekorieren kann nicht Schnittstellen mit Knowntype Weil Contracts-Projekte keine Format-Projekte referenzieren und die Referenzierung das Design bricht. Deshalb möchte ich config verwenden.
Können Sie Ihre Serviceverträge bitte posten –
@hugh: Sicher, aktualisiert. – abatishchev