为什么 WCF 不会自动影响传出消息的 To 标头和传入消息的 ReplyTo?
我有一项服务发送一条消息,并将 ReplyTo 标头设置为返回地址。 我认为:
OperationContext.Current.GetCallbackChannel<IHelloCallback>().RespondHello("tomi");
会自动调用我的客户端,但我收到此异常:
用于在服务器端发送消息 复合双工通道,消息 必须具有“Via”属性或 “To”标头集。
是我做错了什么还是WCF有点懒?
目前,我使用消息检查器的行为来使这些标头匹配,但这似乎有点老套...
ps:我正在使用 MSMQ
更新
我已经创建了两个绑定元素以使 msmq over duplex 工作,它可以在 codeplex 上找到,您可以看到整个示例,但就像我一样说,由于这个错误,我使用消息检查器的行为将传出消息的 To 标头设置为传入消息的 ReplyTo。 奇怪的是我的客户不需要这种行为,他也可以回调我的服务。
I have a service which send a message with the ReplyTo header set to a return address.
I thought that :
OperationContext.Current.GetCallbackChannel<IHelloCallback>().RespondHello("tomi");
will automatically invoke my client, but I receive this exception :
For sending a message on server side
composite duplex channels, the message
must have either the 'Via' property or
the 'To' header set.
Am I doing something wrong or WCF is a little bit lazy ?
Currently, I use a behavior with a message inspector to make these headers match, but it seems a little hacky...
ps : I'm using MSMQ
Update
I've created two binding elements to make msmq over duplex work it's available on codeplex You can see the whole example, but like I said, because of this error I use a behavior with a message inspector to set the To header of outgoing message to the ReplyTo of the incoming message. What is strange is that my client, doesn't need this behavior and he is able tu callback my service too.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否为 MSMQ 创建了自己的自定义绑定以包括双工通信? wsDualHttpBinding 是唯一支持双工通信并因此支持 CallbackContract 机制的 WCF“开箱即用”绑定。
如果您这样做了 - 您可以发布绑定配置吗?
马克
Did you create your own custom binding for MSMQ to include duplex communication? wsDualHttpBinding is the only WCF "out-of-the-box" binding to support duplex communication and thus the CallbackContract mechanism.
If you did - can you please post the binding configuration?
Marc
如果您没有打开可靠会话,则可能会发生此错误。
编辑:
这里是一个似乎已成功使用 MSMQ 传输作为双工传输的人的链接:
http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2006/10/26/8937.aspx
希望有帮助
This error can occur if you do not have reliable session turned on.
EDIT:
Here is a link to someone who seems to have managed to use MSMQ transport as a duplex transport:
http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2006/10/26/8937.aspx
Hope it helps