c# - WCF DataContract - unable to return complex type -
c# - WCF DataContract - unable to return complex type -
i have wcf service has methods homecoming ienumerable<t> collections of objects, , complex type, organizationcollection, has few properties, each ienumerable<t> of different types. believe i've set service contract correctly, , defined types datacontract / datamember correctly. method returns organizationcollection fails exception. know method functions since have unit , integration tests test it. it's when running live , deployed service fails. i've specified type serviceknowntype, no avail. need configure service able homecoming complex types organizationcollection?
note: wcf service running basichttpbinding, , housed in servicehost in windows service.
[system.servicemodel.communicationexception] {"an error occurred while receiving http response http://localhost:8799/myservice. due service endpoint binding not using http protocol. due http request context beingness aborted server (possibly due service shutting down). see server logs more details."} system.servicemodel.communicationexception
[servicebehavior(includeexceptiondetailinfaults = true, automaticsessionshutdown = false, instancecontextmode = instancecontextmode.single)] [serviceknowntype(typeof(organizationcollection))] public class myservice: iclientservice { // ... } [servicecontract] public interface iclientservice { // works: [operationcontract] ienumerable<booksvc> getbooks(datetime sincedate); // fails, above exception: [operationcontract] organizationcollection getorganizations(datetime sincedate); } booksvc defined [datacontract] , each property has [datamember]. true teacher , pupil classes. properties primitive types. organizationcollection defined as:
[datacontract] public class organizationcollection { [datamember] public ienumerable<teacher> teachers { get; set; } [datamember] public ienumerable<student> students { get; set; } }
there 2 options:
concrete collection type (list, etc.) should used homecoming value provide serialization mechanism wcf (collection types in info contracts, msdn).
using known info types (data contract known types, msdn).
c# wcf web-services ienumerable
Comments
Post a Comment