验证DataServiceContext查询响应 [英] Validating DataServiceContext query responses

查看:100
本文介绍了验证DataServiceContext查询响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个SL 4应用程序,它通过DataServicContext访问odata源,我想对odata响应进行验证(例如模式验证)。  我已经四处寻找并且还没有找到一种简单的方法来做到这一点。


我已经迷上了DataServiceContext.ReadingEntity事件,我在其中为每个事务做了一些特殊的处理实体。  我想我可以在这里执行验证,但这已经太晚了,因为此时已经解析了odata条目xml。  理想情况下
我想在DataServiceContext解析xml内容之前挂钩并实例化实体类以执行我的验证,此时我可以验证xml内容(整个文档或每个条目)确保它符合我们的模式/ etc。


我读了一些关于IClientMessageInspector的信息,这似乎有点让人信服,但我无法将它特别地与WCF DataServiceContext联系起来。


谢谢。

解决方案

ReadingEntity是唯一允许在客户端验证响应的地方。 / p>

 


 


 


I have an SL 4 application that accesses an odata source via DataServicContext in which I'd like to perform validation (e.g. schema validation) on the odata responses.  I've searched around and haven't found a straightforward way to do this yet.

I've hooked into the DataServiceContext.ReadingEntity event in which I do some special handling for each entity.  I suppose I could perform validation here, but this is really too late as the odata entry xml has already been parsed at this point.  Ideally I'd like to hook in before the DataServiceContext parses the xml content and instantiates the entity class to perform my validation, at which point I could validate the xml content (either the whole document, or per entry) to make sure it conforms to our schema/etc.

I read some info on the IClientMessageInspector which seemed somewhat promising, but I was unable to relate that specifically to the WCF DataServiceContext.

Thanks.

解决方案

ReadingEntity is the only place that would allow validating the response on the client.

 

 

 


这篇关于验证DataServiceContext查询响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆