I have a WCF service that has methods for returning collections of IEnumerable<T> objects, as well as a complex OrganizationCollection type that has several properties, each of which has IEnumerable<T> different types. I believe that I have correctly set my Service contract and correctly defined my DataContract / DataMember types. The method that OrganizationCollection returns does not work with an exception. I know that the method works, since I have unit and integration tests that test it. This is only when working with a lively and deployed service in which he fails. I even pointed the type as ServiceKnownType , but to no avail. What do I need to do to set up the service to be able to return complex types like OrganizationCollection ?
Note. The WCF service works with basicHttpBinding and is hosted on the ServiceHost in a Windows service.
[System.ServiceModel.CommunicationException] {"An error occurred while receiving an HTTP response at http: // localhost: 8799 / MyService . This may be due to a service endpoint binding that does not use the HTTP protocol. This may also be due to the fact that the HTTP request server is interrupted by the server (possibly due to a service outage). For more information, see the logs. " } System.ServiceModel.CommunicationException
[ServiceBehavior(IncludeExceptionDetailInFaults = true, AutomaticSessionShutdown = false, InstanceContextMode = InstanceContextMode.Single)] [ServiceKnownType(typeof(OrganizationCollection))] public class MyService: IClientService {
BookSvc defined using [DataContract] , and each property has [DataMember] . This is true for teachers and students. All properties are primitive. OrganizationCollection defined as:
[DataContract] public class OrganizationCollection { [DataMember] public IEnumerable<Teacher> Teachers { get; set; } [DataMember] public IEnumerable<Student> Students { get; set; } }
source share