我正在編寫一個雙工服務,供Silverlight 5客戶端使用。我的服務器配置看起來像這樣(在適當的地方很明顯) -PollingDuplexHttpBinding和DuplexChannelFactory - 'ContractFilter不匹配在EndpointDispatcher'
<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不匹配的問題,當我跨過「factory.EndConnect(結果)」,但我不明白爲什麼。很明顯,在服務器上,我實現了異步接口的同步版本(所以只是連接而不是開始/終止連接),但這是我能想到的唯一一個在這裏存在不匹配合同的地方。
我真的把我的頭髮拉出來了......我已經禿頂了!任何幫助將非常感激。
在此先感謝。