PollingDuplexHttpBinding و DuplexChannelFactory - 'ContractFilter عدم تطابق في EndpointDispatcher'

StackOverflow https://stackoverflow.com/questions/9464313

سؤال

أنا أكتب على الوجهين الخدمة التي يستهلكها سيلفرلايت 5 العميل.الخادم التكوين يبدو مثل هذا (في الأماكن الصحيحة الواضح)-

            <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"/>

عقد ترى هناك هذا -

[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();
}

يبدو أن هذا المضيف على ما يرام ولكن لست متأكد 100% من ذلك.

بلدي رمز العميل يبدو مثل هذا -

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

    }

أنا الحصول على ContractFilter مشكلة عدم تطابق عندما كنت خطوة على 'المصنع.EndConnect(نتيجة)' ولكن أنا لا أرى لماذا.من الواضح على الملقم انا تنفيذ متزامن نسخة المتزامن واجهة (حتى مجرد الاتصال لا Begin/EndConnect) ولكن هذا هو المكان الوحيد الذي يمكنني أن أفكر أن تكون متطابقة العقد هنا.

أنا حقا سحب شعري الآن و أنا بالفعل أصلع!أي مساعدة سيكون موضع تقدير حقا.

شكرا مقدما.

هل كانت مفيدة؟

المحلول

يرجى محاولة ذلك من قبل explictly وضع اسم و مساحات من واجهات خدمة, يجب أن لا يكون لديك مشكلة في عدم تطابق بسبب اختلاف CLR مساحات في العميل والخادم.

[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
}

نصائح أخرى

وتذكر تغيير هذا الإصدار من 4.0.0.0 إلى 5.0.0.0 نظرا لأنك تستخدم SL 5 (وأفترض أنك قمت بتحميل System System.servicemodel.pollingduplex من ج: \ ملفات البرنامج (x86) \ MicrosoftSDKS \ Silverlight \ V5.0 \ Libraries \ Server)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top