在WCF服务中,我有两个具有[DataContract]属性的类。其中一个类与另一个类具有“是-α”关系 - 因此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.
更新2:见我的回答如下。
这似乎并不奏效。加载元数据时仍然出现错误。 – 2009-02-04 15:32:56
你看到什么错误? – 2009-02-04 15:49:14