Note that there are some explanatory texts on larger screens.

plurals
  1. POIn WCF, can data contract classes inherit from one another?
    primarykey
    data
    text
    <p>In a WCF service, I have two classes with the [DataContract] attribute. One of these classes has an "is-a" relationship with the other - so class B can inherit from class A. However, when I configure inheritance between these two classes, both denoted with a [DataContract] attribute, the metadata fails to load when testing the services.</p> <p>Is this possible in WCF? Am I missing another attribute?</p> <pre class="lang-cs prettyprint-override"><code>[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; } } </code></pre> <p>NOTE: The custom types are also defined using data contracts.</p> <p><strong>UPDATE</strong>: Below is the error:</p> <blockquote> <p>Error: Cannot obtain Metadata from <a href="http://localhost:8002/GISDataServices/mex" rel="noreferrer">http://localhost:8002/GISDataServices/mex</a> 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 <a href="http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata" rel="noreferrer">http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata</a> Exchange Error URI: <a href="http://localhost:8002/GISDataServices/mex" rel="noreferrer">http://localhost:8002/GISDataServices/mex</a> Metadata contains a reference that cannot be resolved: '<a href="http://localhost:8002/GISDataServices/mex" rel="noreferrer">http://localhost:8002/GISDataServices/mex</a>'. <Code>Receivera:InternalServiceFault</Code>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 &lt;serviceDebug&gt; 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: <a href="http://localhost:8002/GISDataServices/mex" rel="noreferrer">http://localhost:8002/GISDataServices/mex</a> There was an error downloading '<a href="http://localhost:8002/GISDataServices/mex" rel="noreferrer">http://localhost:8002/GISDataServices/mex</a>'. The request failed with HTTP status 400: Bad Request.</p> </blockquote> <p><strong>UPDATE 2:</strong> See my answer below.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload