在控制台应用程序中使用 wcf 双工服务
我有一个 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、[...]
你能帮我吗?提前致谢。
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.config 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是 PollingDuplexHttpBinding 和相关绑定元素仅在 Silverlight API 中可用。因此,当您启动新的 .NET 项目(在您的情况下为控制台应用程序)时,您不能使用相同的代码,因为 .NET 不包含 PollingDuplexBindingElement
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