开发者

Consume a wcf duplex service in console application

开发者 https://www.devze.com 2023-01-22 13:15 出处:网络
I have a wcf duplex service with work fine in silverlight. but the same service I want to consume in windows console application. My code as follow:

I have a wcf duplex service with work fine in silverlight. but the same service I want to consume in windows console application. My code as follow:

   var context = new InstanceContext(this);
   var address = new EndpointAddress("http://localhost:31881/PubSubService.svc");
   var binding = new CustomBinding(
                 new PollingDuplexBindingElement(),
                 new BinaryMessageEncodingBindingElement(),
                 new HttpTransportBindingElement());

    var client = new PubSubClient(context, binding, address);
    client.Publish("topic", "content");

App.co开发者_Python百科nfig is "empty":

   <?xml version="1.0" encoding="utf-8" ?>
     <configuration>
   </configuration>

It give me an error:

Binding 'CustomBinding' doesn't support creating any channel types. This often indicates that the BindingElements in a CustomBinding have been stacked incorrectly or in the wrong order. A Transport is required at the bottom of the stack. The recommended order for BindingElements is: TransactionFlow, ReliableSession, Security, CompositeDuplex, OneWay, StreamSecurity, MessageEncoding, [...]

Could you help me? Thanks in advance.


The problem is that PollingDuplexHttpBinding and related binding element is available only in Silverlight API. So when you start new .NET project (Console application in your case) you can't use the same code, because .NET does not contain PollingDuplexBindingElement

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号