В службе WCF у меня есть два класса с атрибутом [DataContract]. Один из этих классов имеет отношение «is-a» к другому, поэтому класс B может наследовать от класса A. Однако, когда я настраиваю наследование между этими двумя классами, оба обозначаются атрибутом [DataContract], метаданные не загружаются при тестировании услуг.В WCF, могут ли наследовать друг от друга классы контрактов данных?
Возможно ли это в WCF? Я пропустил еще один атрибут?
[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; }
}
ПРИМЕЧАНИЕ. Пользовательские типы также определяются с использованием контрактов данных.
UPDATE: Ниже ошибка:
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: Смотрите мой ответ ниже.
Это не работает. Я по-прежнему получаю сообщение об ошибке при загрузке метаданных. –
Какая ошибка вы видите? –
Большой вопрос. Можете ли вы высказать свою точную ошибку? –