我正在使用 Axis 2 网络服务客户端。
对 web 服务的第一个 https 调用抛出异常并显示消息:“消息不包含有效的安全元素”。
我认为问题可能出在安全模式上:也许它必须是消息级别的安全性。在这种情况下,如何在 Axis 中配置它?
代码:
System.setProperty("javax.net.ssl.keyStore", jksFile);
System.setProperty("javax.net.ssl.keyStorePassword", jksPassword);
MyServicePortProxy proxy = new MyServicePortProxy();
Stub stub = (Stub) proxy.getMyServicePort();
proxy.setEndpoint(endpoint);
stub.setUsername(username);
stub.setPassword(password);
// throws exception with the above message:
proxy.serviceMethod(...);
最佳答案
看看http://ws.apache.org/wss4j/package.html我们必须定义一个 client-config.wsdd 告诉 axis 包含用户名/密码(如果它是您正在使用的 ws-security)。我不太了解不同的标准以及它们之间的区别。
关于java - https Web 服务消息 : Message did not contain a valid Security Element,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/271518/