C#.NET 4.0 WCF MessageSecurityException,“安全头是空的。”消费服务
时,当在一个项目中,我得到一个异常,MesssageSecurityException使用WCF和C#,消息“安全标头是空的。”这里遵循的响应(根据MS服务跟踪查看):C#.NET 4.0 WCF MessageSecurityException,“安全头是空的。”消费服务
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://www.w3.org/2005/08/addressing">      <soapenv:Header> 
     <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="true"></wsse:Security> 
     <wsa:Action>_WHAT_I_DID_</wsa:Action> 
     <wsa:RelatesTo>_MSG_ID_OF_REQUEST_</wsa:RelatesTo> 
     </soapenv:Header> 
     <soapenv:Body> 
     _CORRECT_BODY_ 
     </soapenv:Body> 
    </soapenv:Envelope> 
事实上,安全标头是“空”的,但它仍然是正确的accprding到安全头定义,据我可以告诉。
我也试着编辑绑定,但这似乎并没有很好的帮助。我还发现一个类似的问题,其中EnableUnsecuredResponse可以帮助,但它不在这里。
这里是响应根据了SoapUI:
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://www.w3.org/2005/08/addressing">     <soapenv:Header> 
     <wsse:Security soapenv:mustUnderstand="true" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"/> 
     <wsa:Action>_WHAT_I_DID_</wsa:Action> 
     <wsa:RelatesTo>_REQ_MSG_ID_</wsa:RelatesTo> 
    </soapenv:Header> 
    <soapenv:Body> 
     _CORRECT_BODY_ 
    </soapenv:Body> 
</soapenv:Envelope> 
他们几乎是相同的,除了他们是如何关闭安全头。这很有趣,但不应该引发异常?
我还发现了一个similar problem,其中解决方案是创建一个自定义消息编码器并剥离整个安全标头,尽管这样做可能是一个额外的不必要的步骤。这是使用.Net和WCF的唯一方法吗?不能WCF处理没有内容的安全标头?
编辑: 澄清这个问题,是编写一个编码器,丢弃安全头是唯一的方式来接收和解析带有空的安全头的SOAP消息使用WCF?
EDIT2:添加CONF的一部分:
<binding name="NinjaBinding">      <security allowSerializedSigningTokenOnReply="true" enableUnsecuredResponse="true" 
     authenticationMode="UserNameOverTransport" requireDerivedKeys="false" 
     securityHeaderLayout="Lax" includeTimestamp="false" allowInsecureTransport="true" 
     keyEntropyMode="ClientEntropy" 
     messageProtectionOrder="SignBeforeEncryptAndEncryptSignature" 
    messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" 
     requireSecurityContextCancellation="false"> 
     <localServiceSettings detectReplays="false" /> 
     <secureConversationBootstrap _IDENTICAL_TO_ABOVE_ 
     </secureConversationBootstrap> 
     </security> 
     <textMessageEncoding /> 
     <httpsTransport /> 
    </binding> 
据我所知,它的配置为允许几乎一切吗?
回答:
(现在我回答我的问题,因为我已经能够引发某种形式的答案)通过
总之,不,你不能使用WCF“开箱即用”(即*。配置)与提供空安全标头的应用程序服务器的响应。您必须实现一个编码器,将消息修改为WCF框架可接受的格式。
欲了解更多信息,请阅读this blog其中包含了编码器及其应用的相当不错的演练。 This blog (another blog)还提供了一个代码片段能够解决我的问题,即修改安全标头。
我在想为什么MS和Oracle产品永远不能和平共处:D
以上是 C#.NET 4.0 WCF MessageSecurityException,“安全头是空的。”消费服务 的全部内容, 来源链接: utcz.com/qa/266655.html

