Hello James, Thanks for your answer but it doesn't work :( In fact I change my client code according to your advice: Options options = sc.getOptions(); options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, getRampartConfig()); sc.setOptions(options);
sc.engageModule("rampart"); instead of sc.getAxisService().getPolicyInclude().addPolicyElement(PolicyInclude.AXIS_SERVICE_POLICY, getRampartConfig()); where private Policy getRampartConfig(){ RampartConfig rampartConfig = new RampartConfig(); rampartConfig.setUser("keyalias"); rampartConfig.setPwCbClass("com.gemalto.test.axis2.PWCBHandler"); CryptoConfig sigCrypto = new CryptoConfig(); sigCrypto.setProvider("org.apache.ws.security.components.crypto.Merlin"); Properties props = new Properties(); props.setProperty("org.apache.ws.security.crypto.merlin.keystore.type", "JKS"); props.setProperty("org.apache.ws.security.crypto.merlin.file","D:/Temp/Client.jks"); props.setProperty("org.apache.ws.security.crypto.merlin.keystore.password", "ClientStorePassword"); sigCrypto.setProp(props); rampartConfig.setSigCryptoConfig(sigCrypto); Policy policy = new Policy(); policy.addAssertion(rampartConfig); return policy; } I got a new exception, this time, which is: Exception in thread "main" java.lang.RuntimeException: Undefined 'Security policy namespace cannot be null.' resource property at org.apache.rampart.RampartException.getMessage(RampartException.java:81) at org.apache.rampart.RampartException.<init>(RampartException.java:41) at org.apache.rampart.RampartException.<init>(RampartException.java:57) at org.apache.rampart.RampartMessageData.setWSSecurityVersions(RampartMessageData.java:373) at org.apache.rampart.RampartMessageData.<init>(RampartMessageData.java:261) at org.apache.rampart.MessageBuilder.build(MessageBuilder.java:61) at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:65) 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) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:406) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229) at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165) at com.gemalto.test.axis2.SimpleWSEJBServiceStub.helloWorld(SimpleWSEJBServiceStub.java:187) at com.gemalto.test.axis2.TestSimpleWSAxis2ClientX509.main(TestSimpleWSAxis2ClientX509.java:50) Any idea ? Best Regards. From: James Annesley [mailto:james.annes...@infoshare-is.com] Sent: mardi 31 janvier 2012 21:10 To: java-user@axis.apache.org Subject: RE: Completly lost Hi Francois, I noticed you don't need the server policy file at all on the client side. I do this: client.engageModule("rampart"); options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, null); where client is the ServiceClient. HTH James From: COURTAULT Francois [mailto:francois.courta...@gemalto.com] Sent: 31 January 2012 18:54 To: java-user@axis.apache.org<mailto:java-user@axis.apache.org> Subject: Completly lost Importance: High Hello everybody, I am puzzled :( I use axis2-1.6.0 and rampart-1.6.0 because I have discovered a bug in 1.6.1. Anyway, I try to write axis2 client code by using this axis2 version in order to access to a WS, hosted in Weblogic, protected with the policy attached (policy.xml). When I run my client code several times inside Eclipse, then I met my first issue: the behavior is not the same :) - Sometimes I got: Exception in thread "main" java.lang.NullPointerException at org.apache.rampart.builder.BindingBuilder.getSignatureBuilder(BindingBuilder.java:274) at org.apache.rampart.builder.BindingBuilder.getSignatureBuilder(BindingBuilder.java:250) at org.apache.rampart.builder.AsymmetricBindingBuilder.doSignature(AsymmetricBindingBuilder.java:722) at org.apache.rampart.builder.AsymmetricBindingBuilder.doSignBeforeEncrypt(AsymmetricBindingBuilder.java:419) at org.apache.rampart.builder.AsymmetricBindingBuilder.build(AsymmetricBindingBuilder.java:95) at org.apache.rampart.MessageBuilder.build(MessageBuilder.java:147) at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:64) at org.apache.axis2.engine.Phase.invoke(Phase.java:318) at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:254) at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:419) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229) at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165) at com.gemalto.test.axis2.SimpleWSEJBServiceStub.helloWorld(SimpleWSEJBServiceStub.java:187) at com.gemalto.test.axis2.TestSimpleWSAxis2ClientX509.main(TestSimpleWSAxis2ClientX509.java:44) - Sometimes I got: org.apache.axis2.AxisFault: Error codes: 3201 Error code:3201 at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531) at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229) at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165) at com.gemalto.test.axis2.SimpleWSEJBServiceStub.helloWorld(SimpleWSEJBServiceStub.java:187) at com.gemalto.test.axis2.TestSimpleWSAxis2ClientX509.main(TestSimpleWSAxis2ClientX509.java:44) Is this random behavior normal ? Have you some explanations ? How can we fix it ? I have tested the same client code with Axis1.5.6 and rampart-1.5.2 and I have seen the same random behavior :( I have also seen that I have in my client code some deprecated methods are used: does it explain this random behavior ? The deprecated code lines are: - if (pwcb.getIdentifer().equals("xxx")) - sc.getAxisService().getPolicyInclude().addPolicyElement(PolicyInclude.AXIS_SERVICE_POLICY, rampartConfig); Any advice to replace this deprecated method because I have seen nothing in the javadoc for that :( When I got the second issue (org.apache.axis2.AxisFault: Error codes: 3201 Error code:3201), I made a dump of the exchange and compared it a SOAP request which works. According to my analysis the only difference I saw (I have attached also these two SOAP requests for your own analysis or deeper analysis) is that, in the SOAP request generated by Axis2, in the <KeyInfo <wsse:SecurityTokenReference section, a <wsse:KeyIdentifier section is missing. Do you agree with me or is it something else ? Is it an axis2 bug ? Best Regards. Infoshare Ltd Millennium House 21 Eden Street Kingston upon Thames Surrey KT1 1BL United Kingdom Phone: +44 (0) 20 8541 0111 Support: +44 (0) 20 8481 4760 Web: http://www.infoshare-is.com/ E-mail: i...@infoshare-is.com<mailto:i...@infoshare-is.com> Infoshare Ltd is registered in England and Wales. Registered Office as above. Registered Number 2877612 VAT Number GB 678 1443 10 The content of this e-mail (and any attachment to it) is confidential. Any views or opinions do not represent the views or opinions of Infoshare Ltd. If you have received this e-mail in error please notify the sender and delete it. You may not use, copy or disclose the information in any way. Infoshare Ltd monitors incoming and outgoing e-mails. Please consider the environment. Do you really need to print this email?