我正在使用IBM Liberty 16.0.0.4
我试图通过使用 wsimport 分类的生成客户端来调用 Web 服务,但是当我尝试调用端点服务时,我收到了下一个警告和错误。
[WARNING ] No assertion builder for type {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}TransportBinding registered.
[WARNING ] No assertion builder for type {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}TransportToken registered.
[WARNING ] No assertion builder for type {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}HttpsToken registered.
[WARNING ] No assertion builder for type {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}AlgorithmSuite registered.
[WARNING ] No assertion builder for type {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}Basic256 registered.
[WARNING ] No assertion builder for type {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}Layout registered.
[WARNING ] No assertion builder for type {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}Lax registered.
[WARNING ] No assertion builder for type {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}IncludeTimestamp registered.
[WARNING ] No assertion builder for type {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}SignedSupportingTokens registered.
[WARNING ] No assertion builder for type {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}UsernameToken registered.
[ERROR ] None of the policy alternatives can be satisfied.
None of the policy alternatives can be satisfied.
你知道我是否需要添加额外的 jar 或者我真正的问题是什么?或者缺少什么?
注意:我添加了 Security 和 UsernameToken,它在自定义 SOAPHandler 中具有用户名和密码
谢谢:)
最佳答案
我找到了在 Liberty 服务器上启用 wsSecurity 的解决方案,并且需要显式启用它。
所以我在 <featureManager>
中使用了 wsSecurity-1.1
<feature>wsSecurity-1.1</feature>
另外,为了发送用户名和密码的凭据,我需要使用 UsernameToken 的下一个代码
Map ctx = ((BindingProvider) port).getRequestContext();
ctx.put("ws-security.username", "username");
ctx.put("ws-security.password", "password");
不仅仅是使用安全 SOAP 元素将 UsernameToken 添加到 header 中
security.addChildElement("UsernameToken", "wsse");
引用文献
关于java - 没有类型 {http ://schemas. xmlsoap.org/ws/2005/07/securitypolicy} 的断言构建器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43279615/