WCF CustomBinding + Duplex+ BinaryEncoding + No Security 不能回调 [英] WCF CustomBinding + Duplex+ BinaryEncoding + No Security Cannot Call back

查看:33
本文介绍了WCF CustomBinding + Duplex+ BinaryEncoding + No Security 不能回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Duplex 服务 (Singleton),它曾经与 WSDualHttpBinding 一起使用,但出于性能原因将其更改为双工 CustomBinding 以支持 BinaryEncoding 后,它停止工作.问题追踪到 GetCallBackChannel 总是为所有客户端请求返回相同的 HashCode(在该服务实例中),并且 List 认为它已经存在于订阅的频道中并且不会添加到订阅者列表中.我正在使用 C# 3.5

I have a Duplex service (Singleton), which used to work with WSDualHttpBinding, and after changing it to duplex CustomBinding to support BinaryEncoding for performance reasons, it stopped working. The problem traces to GetCallBackChannel always returns with same HashCode (within that service instance) for all the client requests and the List thinks it already exists in the subscribed channels and wont add to the Subscribers list. I am using C# 3.5

请提出解决方案..

提前致谢...

public void Subscribe(string topicName)
            {
                try
                {
                    Notifier.IPublishing subscriber = OperationContext.Current.GetCallbackChannel<IPublishing>();
                    Notifications.Filter.AddSubscriber(topicName, subscriber);
                }
                catch (Exception ex)
                {
                    ErrorLog.WriteToLog("Subscribe\n" + ex.ToString());
                }
            }

static public void AddSubscriber(String topicName, IPublishing subscriberCallbackReference)
        {
            lock (typeof(Filter))
            {                
                if (SubscribersList.ContainsKey(topicName))
                {
                    if (!SubscribersList[topicName].Contains(subscriberCallbackReference))
                    {
                        SubscribersList[topicName].Add(subscriberCallbackReference);
                    }
                }
                else
                {
                    List<IPublishing> newSubscribersList = new List<IPublishing>();
                    newSubscribersList.Add(subscriberCallbackReference);
                    SubscribersList.Add(topicName, newSubscribersList);
                }
            }
        }

推荐答案

看起来这是 .Net 3.5 的未记录问题.在 .Net 4.0 中尝试了同样的事情,它就像一个魅力.

Looks like this is an Undocumented Issue with .Net 3.5. Tried the same thing in .Net 4.0 it works like a charm.

我的目标是将二进制编码与 wsDualHTTPBinding 结合使用,因为当时无法选择 Windows Server 2008/IIS7.

My objective was to use Binary Encoding with wsDualHTTPBinding, due to the reason that Windows Server 2008/IIS7 was not an option at that time this issue was raised.

使用二进制编码和双工绑定的首选解决方案是使用 nettcpbinding,它依赖于 IIS7(除非您是自托管),该依赖项仅在 Windows Server 2008 或更高版本上可用.

The preferred solution to use binary encoding with duplex binding is to use nettcpbinding, and it has a dependency that that IIS7 (unless you are self hosting) is required which is only available on windows server 2008 or later.

我们说服我们的基础设施小组升级..现在一切都很好:)

We convinced the our infrastructure group to upgrade.. and all is good now :)

这篇关于WCF CustomBinding + Duplex+ BinaryEncoding + No Security 不能回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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