PollingDuplexHttpBinding et DuplexChannelfactory - «ContractFilter Ascramparm sur EndPointDispatcher»

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

Question

J'écris un service duplex qui doit être consommé par un client Silverlight 5. Ma configuration de serveur ressemble à ceci (aux bons endroits évidemment) -

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

Le contrat que vous voyez est ceci -

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

Cela semble héberger très bien, mais je ne suis pas sûr à 100%.

Mon code client ressemble à ceci -

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

    }

J'obtiens un problème de décalage contractuel lorsque je passe en place «Factory.endConnect (résultat)» mais je ne vois pas pourquoi. Évidemment, sur le serveur, j'implémente la version synchrone de l'interface asynchrone (alors connectez-vous et ne commencez pas / endconnect), mais c'est le seul endroit où je peux penser qu'il y a un contrat incompatible ici.

Je tire vraiment mes cheveux maintenant ... et je suis déjà chauve! Toute aide sera grandement appréciée.

Merci d'avance.

Était-ce utile?

La solution

Veuillez l'essayer en définissant de manière expliquée le Nom et espaces de noms De vos interfaces de service, vous ne devriez pas avoir de problème dans un décalage en raison de différentes espaces de noms CLR dans le client et le serveur.

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

Autres conseils

Et n'oubliez pas de changer cette version de 4.0.0.0 à 5.0.0.0 puisque vous utilisez SL 5 (et je suppose que vous avez chargé le bon système System.ServiceModel.PollingDuplex à partir de C: Program Files (x86) Microsoft Sdks Silverlight Light v5.0 bibliothèques serveur)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top