views:

400

answers:

1

Hi,

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

+3  A: 

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" />

    </services>
</services>
<behaviors>
    <serviceBehaviors>
        <behavior name="DataServiceBehavior">
            <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
    </serviceBehaviors>
</behaviors>
Tom Brothers
Hmmm... I thought I'd tried that but I guess I did it wrong somehow. Anyway, getting there... I'm now getting sensible errors back. The one I'm currently working on deals with the fact that my Message class has an enum (Type - error, warning, etc). There's quite a few enums in my code - I'll be a bit annoyed if I can't use any of them :)I guess what I'll do is use IgnoreProperties and add other properties to wrap them as types more friendly to Data Services.Thanks!
JohnL
In case anyone's wondering about the enum thing, apparently you can use them with some extra typing:http://msdn.microsoft.com/en-us/library/aa347875.aspx
JohnL