我已经创建了一个带有服务操作的WCF数据服务.
我想生成一种业务异常.我尝试生成,WebFaultException但我没有看到如何在服务操作抛出此错误时在客户端捕获此错误.
这是我的模拟异常的服务操作:
[WebGet]
public void GenerateException()
{
throw new DataServiceException( 403, "Custom Message" );
}
Run Code Online (Sandbox Code Playgroud)
这是我的客户:
WebClient wc = new WebClient();
wc.DownloadString(
new Uri(
"http://localhost:27820/WcfDataService1.svc/GenerateException"
)
);
Run Code Online (Sandbox Code Playgroud)
DownloadString抛出异常,但它只是Internal Server Error,我看不到我的Custom Message.
任何的想法 ?
非常感谢.
wcf ×1