Pollingduplexhttpbinding y duplexchanfanfactory - 'ContractFilter desajuste en el punto de contacto endpointdispatcher'

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

Pregunta

Estoy escribiendo un servicio dúplex que debe ser consumido por un cliente Silverlight 5.Mi configuración de servidor se ve así (en los lugares correctos obviamente) -

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

El contrato que ve que hay esto -

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

Esto parece alojarse bien, pero no estoy seguro de eso.

Mi código de cliente se ve así -

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

    }

Estoy obteniendo un problema de desajuste de filtro de contrato cuando paso "fábrica.endconnect (resultado) 'pero no veo por qué.Obviamente, en el servidor, estoy implementando la versión síncrona de la interfaz ASYNC (por lo que simplemente conecte y no comienza / endonectecnet), pero ese es el único lugar en el que puedo pensar que hay un contrato desajustado aquí.

Estoy realmente tirando de mi cabello ahora ... ¡y ya estoy calvo!Cualquier ayuda sería realmente apreciada.

gracias de antemano.

¿Fue útil?

Solución

Por favor, inténtelo configurando explicadamente los cuadros de nombres y de sus interfaces de servicio, no debe tener un problema en un desajuste debido a diferentes espacios de nombres de CLR en el clientey servidor.

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

Otros consejos

y recuerde cambiar esa versión desde 4.0.0.0 a 5.0.0.0, ya que está utilizando SL 5 (y supongo que ha cargado el sistema correcto.servicemodel.pollingduplex de C: \ Archivos de programa (x86) \ MicrosoftSDKS \ Silverlight \ v5.0 \ bibliotecas \ servidor)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top