I have an application which will use WCF to serve up various chunks of data to clients. However, due to the size of some of the sets of data that will be returned (and that's because the client app needs to show a large number of objects in a list, not because I've just been lazy in the design) I'm hitting the message size limits.
I expected this, and planned to implement data paging / response streaming (I believe Pablo Cibraro wrote an article on this once). However, I've seen some demos that make WCF Data Services look really cool. I just haven't been able to make it work for me.
I don't have a database back end, and I'm not hosting inside IIS. I have been able to get some examples working on basic objects, but as soon as I plug it into of the objects from my app, it just doesn't work - I get a Request Error, which seems to be designed to be unhelpful - it just suggest checking the server logs without suggesting how I might do this. I suspect it's assuming I am hosting with IIS, and IIS might log messages for data services it hosts.
One reasonably simple class I am trying to work with is for a log message (I want a diagnostic dashboard-style client to be able to remotely show me the server logs from, say, the last 24 hours):
public class Message
{
public string Source { get; set; }
public MessageType Type { get; set; }
public DateTime Timestamp { get; set; }
public string MessageText { get; set; }
public override string ToString()
{
return string.Format("[{0}] [{1}] [{2}] {3}", Timestamp.ToString(), Source, Type, MessageText);
}
}
Using this class generates the error, while if I point it at a class I mock up as a test (as in Pablo's demonstration here: http://msdn.microsoft.com/en-us/data/cc745968.aspx) then it works fine. Any ideas on why this is, or how I can get something useful out of the error?
Below is my service definition and the class I'm using to expose the IQueryable<> implementation of the collections I want to return (at the moment I've only done the Log, which is type List<Message>
)
public class DataServiceFacade
{
public IQueryable<Message> Log
{
get
{
return Program.Log.AsQueryable();
}
}
}
public class DataServiceHost : DataService<DataServiceFacade>
{
public static void InitializeService(IDataServiceConfiguration config)
{
config.UseVerboseErrors = true;
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
}
}
Now, this could be something simple but I've already spent too much time banging my head against this particular brick wall. I was hoping that Data Services would handle things like paging for me, and give me a nice flexible format that will work across different platforms.
Also, if it's not going to be possible to use Data Services for this, I'd appreciate any pointers on data paging or streaming the collection over.
Thanks
It sounds like you are only seeing the generic "Response Error" message. To see the details of that message you need to modify the behavior to "includeExceptionDetailInFaults".
You can change the behavior in your config file.
<services>
<service name="DataServiceHost"
behaviorConfiguration="DataServiceBehavior">
<endpoint name="DataServiceHost"
address=""
binding="webHttpBinding"
contract="System.Data.Services.IRequestHandler" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DataServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With