我需要使用轮询技术来通知客户端有关服务器端的更改。所以我试图使用DuplexHttpBinding(http://code.msdn.microsoft.com/duplexhttp)。我对非安全消息工作正常,但我需要在我的项目(UsernameForCertificate)中使用消息级安全性。好吧,我决定添加SymmetricSecurityBindingElement绑定集合:WCF自定义消息安全
var securityElement = SecurityBindingElement.CreateUserNameForCertificateBindingElement();
collection.Add(securityElement);
然后问题发生了。如果我们使用消息级安全的所有信息包括安全报头与消息签名,这样的:
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
....
</o:Security>
和自定义它们通过自定义的请求信道发送没有安全头轮询消息,因此在发送这个消息出现异常通过与消息级安全通道:
System.ServiceModel.Security.MessageSecurityException, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
No signature message parts were specified for messages with the 'http://samples.microsoft.com/duplexhttp/pollingAction' action.
请咨询解决办法如何把他们自定义的请求通道内之前适当的安全头添加到我的自定义轮询消息。您可以通过之前发布的链接下载源代码,只需使用UsernameForCertificate安全性来重现问题即可。 谢谢。
你在哪里调用你的私有方法'ApplyChannelProtectionRequirements' ?. – 2017-11-19 17:39:33