I am returning a complex type from my WCF service (which is hosted in SharePoint 2010) and I wan to be able to return an array (or collection of some type) as a property.
The aim is to have a generic Type that contains standard stuff like Error, Message and an array of Data.
On the server I am using proper types and only want the array of objects to be returned in the JSON.
It works fine if I return an collection of the real type...but casting to objects causes a login challenge (which seem weird) and even as the admin...I can't get past it.
public class MyServiceReponse
{
public List<string> Errors { get; set; }
public List<string> Messages { get; set; }
public bool Success { get; set; }
public int DataCount { get; set; }
public object[] ResponseData { get; set; }
public IEnumerable<MyOtherType> Sites { get; set; }
public MyServiceReponse()
{
Errors = new List<string>();
Messages = new List<string>();
Success = true;
}
public void AddError(Exception ex)
{
Success = false;
Errors.Add("Oooops, there seems to be a problem. (" + ex.Message + ")");
}
}
public class MyOtherType
{
public string Name { get; set; }
public string Ticker { get; set; }
public string Other { get; set; }
}
How would I go about achieving this?
First I though I would just have ResponseData as an object...setting my collection to it...but that doesn't work either.
Thx
No comments:
Post a Comment