I have a WCF service with a service interface
[ServiceContract]
public interface IMyService
{
[OperationContract]
[ServiceKnownType(typeof(Person))]
[ServiceKnownType(typeof(Employee))]
IPerson GetPerson();
}
and my Implementation of GetPerson is
public IPerson GetPerson()
{
IPerson obj = new Person();
obj.FirstName = "Bhuvan";
obj.LastName = "Ram";
return obj;
}
And in my client as simple I used
KnownType.MyServiceClient obj = new KnownType.MyServiceClient();
Person objp = (Person)obj.GetPerson()'
But when I am trying to access, I am receiving an error
The underlying connection was closed: The connection was closed unexpectedly.
and my stack trace is like this
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)..
My Employee Class is
> [DataContract(Name = "Employee")] [KnownType(typeof(IEmployee))]
public class Employee:IEmployee { [DataMember] public string EmployeeName { get;set; } }> My Person Class is [DataContract(Name = "Person")] [KnownType(typeof(IPerson))]
public class Person: IPerson {
#region IPerson Members [DataMember(Name = "FirstName")] public string FirstName { get; set; }
[DataMember(Name = "LastName")]
public string LastName { get; set; }
#endregion
}
How do I resolve this?