我正在尝试使用带有壁垒的axis2中的用户名令牌生成安全性。
String securityPolicyPath = "/WEB-INF/policy.xml";
ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("/axis2-1.6.2/repository/", "/WEB-INF/conf/axis2.xml");
CalAddStub stub = new CalAddStub(ctx,"http://localhost:8090/RampartTest/services/CalAdd/");
ServiceClient sc = stub._getServiceClient();
sc.engageModule("rampart");
Options options = sc.getOptions();
options.setUserName("apache");
options.setPassword("password");
options.setProperty(RampartMessageData.KEY_RAMPART_POLICY,loadPolicy(securityPolicyPath));
Add_cal add = new Add_cal();
add.setX(6);
add.setY(9);
System.out.println("id = " + stub.add_cal(add).get_return());
但我得到了这个例外。
[INFO] Deploying Web service: version.aar - file:/C:/axis2-1.6.2/repository/services/version.aar
Exception in thread "main" java.lang.NoClassDefFoundError: org/jaxen/JaxenException
at org.apache.rampart.handler.WSDoAllSender.processBasic(WSDoAllSender.java:108)
at org.apache.rampart.handler.WSDoAllSender.processMessage(WSDoAllSender.java:72)
at org.apache.rampart.handler.WSDoAllHandler.invoke(WSDoAllHandler.java:72)
at org.apache.axis2.engine.Phase.invokeHandler(Phase.java:340)
at org.apache.axis2.engine.Phase.invoke(Phase.java:313)
at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:262)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:427)