开发者

WCF CustomBinding + Duplex+ BinaryEncoding + No Security Cannot Call back

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

Please suggest a solution..

Thanks in Advance...

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(to开发者_开发问答picName))
                {
                    if (!SubscribersList[topicName].Contains(subscriberCallbackReference))
                    {
                        SubscribersList[topicName].Add(subscriberCallbackReference);
                    }
                }
                else
                {
                    List<IPublishing> newSubscribersList = new List<IPublishing>();
                    newSubscribersList.Add(subscriberCallbackReference);
                    SubscribersList.Add(topicName, newSubscribersList);
                }
            }
        }


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

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.

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 :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜