在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