I am new to WCF and I am trying to serialize a list of custom objects. I have already tried the solutions in other articles.
Here is the service interface code:
[ServiceContract]
[ServiceKnownType(typeof(List<Stage>))]
public interface IUserService
{
[OperationContract]
void CreateUser(string name, string pwd, bool admin);
[OperationContract]
bool LogInUser(string name, string pwd);
[OperationContract]
List<Stage> getAllStages();
}
[DataContract]
public class StageListGetter
{
private List<Stage> stageList;
[DataMember]
public List<Stage> StageList
{
get { return stageList; }
set { stageList = value; }
}
}
In the service class I have tried this:
public List<Stage> getAllStages()
{
StageController sctrl = new StageController();
Dictionary<int, Stage> sdict = sctrl.getAllStages();
List<Stage> StageValueList = sdict.Values.ToList();
StageListGetter sg = new StageListGetter();
sg.StageList = StageValueList;
return sg.StageList;
}
And have the following error on invocation:
This could be due to the service endpoint binding not using the HTTP protocol.
This could also be due to an HTTP request context being aborted by the server (possibly due
to the service shutting down). See server logs for more details.
What am I missing?