Answered by:
How to config PollingDuplexHttpBinding in ServiceReferences.ClientConfig ?

Question
-
Hi Expert,
We use polling duplex in our Silverlight app, it is easier to set the config file in WCF service side as follows, however, how to set the config file in Silverlight client side?
<extensions>
<bindingExtensions>
<add name="pollingDuplexHttpBinding" type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement, System.ServiceModel.PollingDuplex, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</bindingExtensions>
</extensions>
<bindings>
<pollingDuplexHttpBinding/>
</bindings>
Is there any approach to set this? So that there is no need for us to rebuild the project every time when deploy on different server.
***********************
BTW, one article in MSDN http://msdn.microsoft.com/en-us/library/cc197941(VS.95).aspx show the following:
(The other standard binding available is the PollingDuplexHttpBinding, which configures a service endpoint for duplex communication with a polling client, but this binding must be configured in code, not in the ServiceReferences.ClientConfig file.)
However, how to set the binding info in config file? Any success implementation on this?
Enjoy lifeMonday, May 17, 2010 6:23 AM
Answers
-
On Silverlight 3, you cannot configure a PollingDuplex binding in config. You'd need to do something like
PollingDuplexHttpBinding binding = new PollingDuplexHttpBinding();
EndpointAddress address = new EndpointAddress("http://your.server/vdir/path_to_svc_file");
MyDuplexClient client = new MyDuplexClient(binding, address);
client.OnHelloReceived += ...
client.HelloAsync(...)On Silverlight 4, you can use config to define a polling duplex binding / endpoint as well, although you'll only be able to use custom bindings for that:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="pd">
<pollingDuplex duplexMode="SingleMessagePerPoll"/>
<binaryMessageEncoding />
<httpTransport/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://your.server/vdir/path_to_svc_file.svc"
binding="customBinding"
bindingConfiguration="pd"
contract="IDuplexService"
name="MyDuplexContract"/>
</client>
</system.serviceModel>- Proposed as answer by Carlos Figueira Friday, May 21, 2010 8:34 AM
- Marked as answer by Mog Liang Monday, May 24, 2010 2:39 AM
Monday, May 17, 2010 9:42 PM
All replies
-
On Silverlight 3, you cannot configure a PollingDuplex binding in config. You'd need to do something like
PollingDuplexHttpBinding binding = new PollingDuplexHttpBinding();
EndpointAddress address = new EndpointAddress("http://your.server/vdir/path_to_svc_file");
MyDuplexClient client = new MyDuplexClient(binding, address);
client.OnHelloReceived += ...
client.HelloAsync(...)On Silverlight 4, you can use config to define a polling duplex binding / endpoint as well, although you'll only be able to use custom bindings for that:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="pd">
<pollingDuplex duplexMode="SingleMessagePerPoll"/>
<binaryMessageEncoding />
<httpTransport/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://your.server/vdir/path_to_svc_file.svc"
binding="customBinding"
bindingConfiguration="pd"
contract="IDuplexService"
name="MyDuplexContract"/>
</client>
</system.serviceModel>- Proposed as answer by Carlos Figueira Friday, May 21, 2010 8:34 AM
- Marked as answer by Mog Liang Monday, May 24, 2010 2:39 AM
Monday, May 17, 2010 9:42 PM -
I have a question about that,
what is the new code C# of the client ?
Thanks
Friday, October 22, 2010 9:32 AM -
On SL4, if you have config, you can do something like
MyDuplexClient client = new MyDuplexClient("MyDuplexContract"); // the "name" attribute of the endpoint element
instead of the first three lines (create binding, create endpoint address, use them to create the client).
Friday, October 22, 2010 5:33 PM -
what if i am using MultipleMessagesPerPoll? the above did not workWednesday, February 9, 2011 10:18 PM