如何在WCF中处理异常 [英] How to handle exception in WCF

查看:74
本文介绍了如何在WCF中处理异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个wcf服务。在我的服务中,我正在验证数据并将数据保存在db中。当我的客户端发送错误的数据时,我返回一些必填字段为空。但每当我的客户端向我发送正确的数据时,我在db中保存数据并返回成功消息,但如果我的数据库抛出异常,但在这里我不想返回有失败消息的客户端,这里我想要召回数据库并保存数据如何在我的服务中处理这个要求,但我想在异常时释放呼叫并带有成功消息



我是什么尝试过:



现在我还没试过任何东西

I have a wcf service. in my service i am validating the data and saving the data in db. when my client send the wrong data i am returning some mandatory fields are empty. but whenever my client send a correct data to me that time am saving the data in db and am returning the success message but if my db throw an exception but here i don't want to return to the client with failure message, here i want to recall the db and save the data how can i handle this requirement in my service but i want to release the call at exception with success message

What I have tried:

as off now i haven't tried anything

推荐答案

它很容易找到的信息。正如RayanDev所说。只需编写代码!

WCF错误处理Microsoft Docs [ ^ ]



祝你好运!
It is very easy information to find. As RayanDev also said. Just write the code!
WCF Error Handling | Microsoft Docs[^]

Good luck!


这篇关于如何在WCF中处理异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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