In un servizio WCF, ho due classi con l'attributo [DataContract]. Una di queste classi ha una relazione "is-a" con l'altra - quindi la classe B può ereditare dalla classe A. Tuttavia, quando configuro l'ereditarietà tra queste due classi, entrambe con un attributo [DataContract], i metadati non vengono caricati durante il test dei servizi.In WCF, le classi di contratto dati possono ereditare l'una dall'altra?
È possibile in WCF? Mi manca un altro attributo?
[DataContract]
public class A
{
[DataMember]
public MyCustomType AValue1{ get; set; }
[DataMember]
public MyCustomType AValue2 { get; set; }
}
[DataContract]
public class B: A
{
[DataMember]
public double BValue1{ get; set; }
[DataMember]
public double BValue2 { get; set; }
}
NOTA: i tipi personalizzati vengono anche definiti mediante contratti di dati.
UPDATE: Di seguito è riportato l'errore:
Error: Cannot obtain Metadata from http://localhost:8002/GISDataServices/mex If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: http://localhost:8002/GISDataServices/mex Metadata contains a reference that cannot be resolved: ' http://localhost:8002/GISDataServices/mex '.
Receivera:InternalServiceFault
The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.HTTP GET Error URI: http://localhost:8002/GISDataServices/mex There was an error downloading ' http://localhost:8002/GISDataServices/mex '. The request failed with HTTP status 400: Bad Request.
UPDATE 2: Vedere la mia risposta qui sotto.
Questo non sembra funzionare. Ricevo ancora un errore durante il caricamento dei metadati. –
Qual è l'errore che stai vedendo? –
Ottima domanda. Puoi pubblicare il tuo errore esatto? –