I'm writing a duplex service which is to be consumed by a Silverlight 5 client. My server config looks like this (in the right places obviously)-
<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"/>
The contract you see there is this -
[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();
}
This seems to host just fine but I'm not 100% sure of that.
My client code looks like this -
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);
}
I'm getting a ContractFilter mismatch problem when I step over 'factory.EndConnect(result)' but I don't see why. Obviously on the server I'm implementing the synchronous version of the Async interface (So just Connect and not Begin/EndConnect) but that's the only place I can think of there being a mismatched contract here.
I'm really pulling my hair out now...and I'm already bald! Any help would be really appreciated.
Thanks in advance.