c# - 我怎样才能让 WCF 路由给我一个比没有匹配的 MessageFilter 更详细的错误消息?

标签 c# wcf appfabric wcf-routing

有没有一种方法可以配置 WCF 路由,这样如果您的过滤器不匹配,您可以获得有关无法路由的消息的更多信息?

目前我们正在使用 AppFabric,我们只收到以下消息。 在尝试找出哪条消息与过滤器不匹配时,此消息不是很有帮助。

No matching MessageFilter was found for the given Message.

最佳答案

这不是最好的解决方案,我一直在试验一种方法来验证路由服务是否按配置工作,但还没有找到最好的方法。

但一种方法是提供一个匹配所有过滤器,并有一个服务接受所有请求并记录它,并将 404 返回给客户端

    <routing>
        <filters>
            <filter name="Other" filterType="MatchAll" />
            <filter name="action1" filterType="Action" filterData="http://tempuri.org/action2" />
            <filter name="action2" filterType="Action" filterData="http://tempuri.org/action1" />
        </filters>
        <filterTables>
            <filterTable name="FilterTable">
                <add filterName="action1" endpointName="Service1" priority="1" />
                <add filterName="action2" endpointName="Service2" priority="1" />
                <add filterName="Other" endpointName="Logger" priority="0" />
            </filterTable>
        </filterTables>
    </routing>

Logger 端点简单地指向一个简单的服务,该服务接受消息并记录它,并返回 404

一些伪代码:

[ServiceBehavior]
public class RoutingLogger : IYourInterface
{
    public System.ServiceModel.Channels.Message YourInterfaceMethod(System.ServiceModel.Channels.Message message)
    {
        LogMessage(message);
        return new Custom404Message();
    }
}

关于c# - 我怎样才能让 WCF 路由给我一个比没有匹配的 MessageFilter 更详细的错误消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6311423/

相关文章:

java - 将图像文件从 Android 发送到 WCF REST 服务

azure - 应用程序结构缓存监视器

c# - AppFabric 1.0错误服务器集合不能为空

c# - 返回 HttpResponseMessage 并且配置了 Application Insights 时,WebAPI 响应永远不会完成

c# - Double.Parse 在德语语言环境中失败

wcf - 使用 Azure Blob 存储从 WCF REST 下载文件

c# - JQuery 中的 JSON 格式问题

wcf - Net Messaging 绑定(bind)轮询间隔和并发性

c# - 在 stringbuilder 中搜索字符串并替换整行 C#

c# - 在 C# 控制台应用程序中播放 mp3 声音