【问题标题】:Consume a wcf duplex service in console application在控制台应用程序中使用 wcf 双工服务
【发布时间】:2010-10-26 10:01:05
【问题描述】:

我有一个 wcf 双工服务,在 silverlight 中可以正常工作。但我想在 Windows 控制台应用程序中使用相同的服务。我的代码如下:

   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.config 为“空”:

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

它给了我一个错误:

绑定“CustomBinding”不支持创建任何通道类型。这通常表明 CustomBinding 中的 BindingElement 堆叠不正确或顺序错误。堆栈底部需要传输。 BindingElements 的推荐顺序是:TransactionFlow、ReliableSession、Security、CompositeDuplex、OneWay、StreamSecurity、MessageEncoding、[...]

你能帮帮我吗?提前致谢。

【问题讨论】:

    标签: wcf wcf-binding duplex pollingduplexhttpbinding


    【解决方案1】:

    问题在于 PollingDuplexHttpBinding 和相关的绑定元素仅在 Silverlight API 中可用。因此,当您启动新的 .NET 项目(在您的情况下为控制台应用程序)时,您不能使用相同的代码,因为 .NET 不包含 PollingDuplexBindingElement

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多