PollingDuplexHttpBindingとDuplexChannelfactory - 'EndpointDispatcherでのContractFilterの不一致'
-
13-11-2019 - |
質問
Silverlight 5クライアントによって消費されるデュプレックスサービスを書いています。My Server Configはこのようになります(明らかに正しい場所で) -
<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);
}
.
'factory.endconnect(結果)を降りると、契約フィルタの不一致問題が発生しましたが、その理由はわかりません。明らかにサーバー上では、非同期インターフェイスの同期バージョンを実装しています(SOGHCの場合、begin / endConnectだけでなく、接続されていません)が、ここでは不一致の契約があると考えることができる唯一の場所です。
私は本当に私の髪を今抜け出しています...そして私はもうハゲです!任意の助けが本当に感謝されるでしょう。
事前にありがとうございました。
解決
サービスインタフェースの name とネームスペースを説明することで試してください。クライアント内の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
}
他のヒント
で、SL 5を使用しているため、4.0.0.0から5.0.0.0のバージョンを変更することを忘れないでください(そして、C:\ Program Files(x86)\ Microsoftから正しいSystem.ServiceModel.PollingDuplexアセンブリをロードしたことを確認しています)。SDKS \ Silverlight \ V5.0 \ Libraries \ Server)