que desarrollo (reescribir en WCF) un análisis de archivos de servicios web aceptando string[]
y volviendo ISection[]
pero en realidad se trata de un conjunto de interfaces anidadas:Contrato de datos tipos conocidos y un conjunto de interfaces de heredar entre sí
namespace Project.Contracts // Project.Contracts.dll
{
public interface ISection { }
public interface ISummarySection : ISection { }
public interface IDataSection : ISection { }
}
y clases:
namespace Project.Format.A // Project.Format.A.dll
{
[DataContract]
public class SummarySectionFormatA : ISummarySection { }
[DataContract]
public class DataSectionFormatA : IDataSection { }
}
interfaz de servicio y su implementación:
[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);
}
}
probé a configurar declaredTypes
tanto en el servidor y los clientes:
<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>
Pero teniendo el mismo error:
"Type 'DataSectionFormatA' with data contract name 'DataSection:http://schemas.example.com/Parse' is not expected.
o
The underlying connection was closed: The connection was closed unexpectedly.
no puede decorar con las interfaces KnownTypeAttribute porque los proyectos de Contratos no hacen referencia a los proyectos de Formato, y la referencia rompe el diseño. Es por eso que quiero usar config.
Puedes publicar tus contratos de operación de servicio por favor –
@hugh: Claro, actualizado. – abatishchev