首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PollingDuplexHttpBinding和DuplexChannelFactory -“EndpointDispatcher上的ContractFilter不匹配”

PollingDuplexHttpBinding和DuplexChannelFactory -“EndpointDispatcher上的ContractFilter不匹配”
EN

Stack Overflow用户
提问于 2012-02-27 19:33:17
回答 2查看 1.3K关注 0票数 1

我正在编写一个供Silverlight5客户端使用的双工服务。我的服务器配置看起来像这样(显然是在正确的地方)-

代码语言:javascript
复制
            <bindingExtensions>
                <add name="pollingDuplexHttpBinding"
                     type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement, System.ServiceModel.PollingDuplex, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            </bindingExtensions>

<pollingDuplexHttpBinding>
                <binding name="multipleMessagesPerPollPollingDuplexHttpBinding"
                         duplexMode="MultipleMessagesPerPoll"
                         maxOutputDelay="00:00:07"/>
            </pollingDuplexHttpBinding>

<endpoint address="Duplex"
                          binding="pollingDuplexHttpBinding"
                          bindingConfiguration="multipleMessagesPerPollPollingDuplexHttpBinding"
                          contract="ProActive.Domain.Interfaces.IDuplexService"/>

你看到的合同是这样的-

代码语言:javascript
复制
[ServiceContract(Name = "IDuplexService", CallbackContract = typeof(IDuplexClient))]
    public interface IDuplexServiceAsync
    {
        [OperationContract(AsyncPattern = true)]
        IAsyncResult BeginConnect(int userId, AsyncCallback callback, object asyncState);

        void EndConnect(IAsyncResult result);
    }

[ServiceContract]
public interface IDuplexClient
{
    [OperationContract(IsOneWay = true)]
    void Refresh();
}

这个主机似乎还不错,但我不能百分之百地确定。

我的客户代码看起来像这样-

代码语言:javascript
复制
public class client : IDuplexClient
{
    #region IDuplexClient Members

    public void Refresh()
    {

    }

    #endregion
}



 public someOtherClass
    {
var binding = new PollingDuplexHttpBinding();
            binding.DuplexMode = PollingDuplexMode.MultipleMessagesPerPoll;

            var address = new EndpointAddress("http://" + ConfigService.ServerName + "/Service.svc/Duplex/");

            var factory = new DuplexChannelFactory<IDuplexServiceAsync>(
                new InstanceContext(new client()), binding).CreateChannel(address);
            factory.BeginConnect(0, new AsyncCallback((result) =>
                {
                    factory.EndConnect(result);

                }), null);

    }

当我跨过‘factory.EndConnect( ContractFilter )’时,我得到了一个结果不匹配的问题,但我不明白为什么。显然,在服务器上,我正在实现异步接口的同步版本(所以只实现Connect而不是Begin/EndConnect),但这是我能想到的唯一不匹配的契约。

我真的很难受,我已经谢顶了。now...and。任何帮助都将不胜感激。

提前谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-08-08 12:17:26

请通过明确设置您的服务接口的name namespaces 来尝试一下,您应该不会因为客户端和服务器端的CLR命名空间不同而出现不匹配的问题。

代码语言:javascript
复制
[ServiceContract(Name = "IClient", Namespace = "http://your.namespace")]
public interface IClient
{
    [OperationContract(IsOneWay = true)]
    void DoSomething();

    [OperationContract(IsOneWay = true)]
    void DoSomethingElse();
}

[ServiceContract(Name = "IServer", Namespace = "http://your.namespace", CallbackContract = typeof(IClient))]
public interface IServer
{
#if !SILVERLIGHT
    [OperationContract]
    string Operation1(string userName);

    [OperationContract]
    int Operation2(int x, int y);
#else
    [OperationContract(AsyncPattern = true)]
    IAsyncResult BeginOperation1(string userName, AsyncCallback callback, object state);
    string EndOperation1(IAsyncResult asyncResult);

    [OperationContract(AsyncPattern = true)]
    IAsyncResult BeginOperation2(int x, int y, AsyncCallback callback, object state);
    int EndOperation2(IAsyncResult asyncResult);
#endif
}
票数 2
EN

Stack Overflow用户

发布于 2013-09-27 00:16:51

记住将版本从4.0.0.0改为5.0.0.0,因为您使用的是SL5(我假设您已经从c:\Program Files (x86)\Microsoft \Silverlight\v5.0\Libraries\ System.ServiceModel.PollingDuplex加载了正确的服务器程序集)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9464313

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档