[英]WCF Exception handling with batch operations
I need an hint on this architectural problem. 我需要一个关于这个架构问题的提示。
My application calls different wcf services that perform specific tasks returning a list of model objects. 我的应用程序调用不同的wcf服务,这些服务执行返回模型对象列表的特定任务。
Say, I have a service which polls stock exchange titles returning a List<SeTitle>
. 说,我有一个服务,轮询股票交易所标题返回
List<SeTitle>
。 [Purely fictional example, I'm reading a book on this subject] [纯粹是虚构的例子,我正在读一本关于这个主题的书]
If an exception happens in one or few elements of this list I have two options in the wcf service: 如果此列表中的一个或几个元素发生异常,则wcf服务中有两个选项:
My will is to go for a third option, meaning that I'll always return my List but with the evidence of faulty items. 我的意愿是选择第三个选项,这意味着我将始终返回我的列表,但要提供有缺陷的项目的证据。
My idea is to let all my model object extend a simple interface like (pardon names, they are horrible) 我的想法是让我所有的模型对象扩展一个简单的接口,例如(对不起的名字,它们很可怕)
public interface IWcfReturnObject
{
public List<WarningModel> Warnings;
}
and 和
public class SeTitle : IWcfReturnObject
in a such a way each element of the list could have an associated List of Warnings/Error to be returned to the application and then to the interface. 以这种方式,列表的每个元素可以具有关联的警告/错误列表,以将其返回给应用程序,然后返回给界面。
My questions are: 我的问题是:
Thanks 谢谢
M. M.
EDIT: I was doing research and looking at the first answer I think it is useful to give one solution I found on the NET 编辑:我正在做研究,并看着第一个答案,我认为给出我在NET上找到的一个解决方案很有用
Possible Solutions 可能的解决方案
I think you should log your exceptions/errors/warnings instead of sending them along with result data. 我认为您应该记录您的异常/错误/警告,而不是将它们与结果数据一起发送。 You can always refer to log and maybe create an interface to see error log.
您始终可以参考日志,也可以创建一个界面来查看错误日志。 But, common result data should not be mixed with exception data.
但是,常见结果数据不应与异常数据混合。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.