时,当在一个项目中,我得到一个异常,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服务?乳清是安全包头,如果它是空的,甚至包括在内?请求中使用了什么安全性? –
安全的conf,basicly只是'UserNameOverTransport'和https传输结合,其余应根据WS-规范并不重要(我已经通过每一个App.config中设置了AFAIK)。非WCF通过SOAP。为什么包含头文件?我不知道?但我的客户只是在使用服务器。 req中的安全性与conf相同。问题是这样的:你是否必须编写一个自定义消息编码器,或者你可以通过某种方式配置WCF来在不实现编码器的情况下删除安全头部? – flindeberg
你的意思是你正在使用的安全模式=运输或TransportWithMessageCredential? –