WCF数据服务-如何诊断请求错误?
我有一个应用程序,它将使用 WCF 向客户端提供各种数据块。但是,由于将返回的某些数据集的大小(这是因为客户端应用程序需要在列表中显示大量对象,而不是因为我在设计中偷懒),我'我达到了消息大小限制。
我预料到了这一点,并计划实现数据分页/响应流(我相信 Pablo Cibraro 曾就此写过一篇文章)。不过,我见过一些使 WCF 数据服务看起来非常酷的演示。我只是没能让它为我工作。
我没有数据库后端,并且不在 IIS 内托管。我已经能够获得一些适用于基本对象的示例,但是一旦我将其插入到我的应用程序中的对象中,它就不起作用 - 我收到一个请求错误,这似乎被设计为没有帮助 -它只是建议检查服务器日志,而不建议我如何执行此操作。我怀疑它假设我使用 IIS 进行托管,并且 IIS 可能会记录其托管的数据服务的消息。
我尝试使用的一个相当简单的类是日志消息(我希望诊断仪表板式客户端能够远程向我显示过去 24 小时内的服务器日志):
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);
}
}
使用此类会生成错误,而如果我将它指向一个我模拟为测试的类(如 Pablo 的演示所示:http://msdn.microsoft.com/en-us/data/cc745968.aspx)然后它工作正常。关于为什么会出现这种情况的任何想法,或者我如何从错误中获得有用的东西?
下面是我的服务定义和我用来公开 IQueryable<> 的类。实现我想要返回的集合(目前我只完成了 Log,其类型为 List
)
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);
}
}
现在,这可能很简单,但我已经花了太多钱时间把我的头撞到了这堵特殊的砖墙上。我希望数据服务能够为我处理诸如分页之类的事情,并为我提供一种可以跨不同平台工作的灵活格式。
另外,如果无法为此使用数据服务,我将不胜感激有关数据分页或流式传输集合的任何指示。
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您只看到通用的“响应错误”消息。要查看该消息的详细信息,您需要将行为修改为“includeExceptionDetailInFaults”。
您可以更改配置文件中的行为。
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.