检测FaultException是否来自远程源

时间:2017-09-04 13:04:28

标签: .net wcf faultexception

我有一个分布式服务器应用程序。

客户端连接到从属服务器并调用传播到主服务器的方法。主服务器抛出FaultException<CustomFault>()

从服务器然后将FaultException<CustomFault>()传播到连接的客户端。但客户端会收到非通用的FaultException

如果我在从属服务器上捕获并重新抛出它(在FaultException<CustomFault>创建一个新实例),它将按预期工作:

    protected void Rethrow(Action action)
    {
        try
        {
            action();
        }
        catch (FaultException<CustomFault> kEx)
        {
            throw new FaultException<CustomFault>(kEx.Detail);
        }
    }

因此我假设我的所有接口都正确装饰。我只能假设microsoft认为通过多个服务器抛出FaultExceptions被认为是一个安全问题......

如何识别从其他服务器抛出FaultException?检查调用堆栈:

Server stack trace: 
  at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
  at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
  at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
  at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

对我来说似乎不对。有更好的想法吗?

1 个答案:

答案 0 :(得分:0)

如果其他人有同样的问题:

如果FaultException来自远程来源 - Action属性会显示该服务!

相关问题