检测 FaultException 是否来自远程源

Detect if FaultException is from remote source

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

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

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

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

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

因此我假设我所有的界面都被正确装饰了。我只能假设微软认为通过多个服务器抛出 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)

我觉得不对。有更好的想法吗?

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

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