PollingDuplexHttpBinding は Silverlight のための双方向通信するバインディングです。 サービス側 †Web.config 設定 バインディングを追加 PollingDuplexHttpBinding は標準なバインディングではないため、利用するために、「参照」に追加する必要があります、そして「bindingExtensions」タグに登録する必要があります。PollingDuplexHttpBinding アセンブリの場所は %ProgramFiles%\Microsoft SDKs\Silverlight\v4.0\Libraries\Server\System.ServiceModel.PollingDuplex.dll <extensions> <bindingExtensions> <add name= "pollingDuplexHttpBinding" type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,System.ServiceModel.PollingDuplex, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> </bindingExtensions> </extensions> バインディングの設定 <bindings> <pollingDuplexHttpBinding> <binding name="pollingDuplexHttpBindingSetting" duplexMode="MultipleMessagesPerPoll" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" maxOutputDelay="00:00:00"/> </pollingDuplexHttpBinding> </bindings> サービスの設定 <service name="Sample1.MyService"> <endpoint address="" binding="pollingDuplexHttpBinding" bindingConfiguration="pollingDuplexHttpBindingSetting" contract="Sample1.MyService"> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> サービスの実装は双方向通信によるサーバープッシュ参照ください。 クライアント側 †サービス側と同じ、PollingDuplexHttpBinding バインディングを利用するために、「参照」に追加する必要があります。 具体の実装は、双方向通信によるサーバープッシュ参照ください。 ソースコードによるプロキシの実装は public static MyServiceClient GetMyServiceClient() { //バインディングの定義 PollingDuplexHttpBinding binding = new PollingDuplexHttpBinding(PollingDuplexMode.MultipleMessagesPerPoll); binding.DuplexMode = PollingDuplexMode.MultipleMessagesPerPoll; binding.MaxReceivedMessageSize = int.MaxValue; binding.MaxBufferSize = int.MaxValue; //参照するサービスはアクセスするURLの直下に配置されていることとする return new MyServiceClient( binding, new EndpointAddress( new Uri(Application.Current.Host.Source, "../MyService.svc")) ); } 月額たった 1,050円で始められる本格的なお店のホームページ! コメント:
|