我的WSDL文件中有以下策略:
<wsp:Policy wsu:Id="UsernameToken"
xmlns:wsp="http://www.w3.org/ns/ws-policy"
xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
>
<wsap:UsingAddressing xmlns:wsap="http://www.w3.org/2006/05/addressing/wsdl"/>
<sp:SymmetricBinding>
<wsp:Policy>
<sp:ProtectionToken>
<wsp:Policy>
<sp:SecureConversationToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient" />
</wsp:Policy>
</sp:ProtectionToken>
</wsp:Policy>
</sp:SymmetricBinding>
</wsp:Policy>
我把它包含在绑定中:
<wsp:PolicyReference xmlns:wsp="http://www.w3.org/ns/ws-policy" URI="#UsernameToken"/>
看起来它通过了WSDL,除了我在我的处理程序中的时候:
List<?> securityList = soapEnvelope.getSecurity(null, true);
if ((securityList == null) || (securityList.size() == 0))
{
securityList = soapEnvelope.getSecurity();
}
返回 null 。 soapEnvelop在这里是: WSSOAPEnvelope soapEnvelope,它不是null;
非常感谢你的帮助!一直在努力解决这个问题。
我感觉安全标头正在从信封中裁剪。
此外,如果我从WSDL文件中删除策略定义,那么它将在没有soap:mustUnderstand="1"
的情况下传递,如果我确实包含此属性,那么它会给我错误消息:
MustUnderstand headers:[{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security] are not understood