2012/2/1 COURTAULT Francois <francois.courta...@gemalto.com> > In fact the simple question I have is: Is there any sample/tutorial > available somewhere in order to have a client code which doesn’t need to > have an external policy file available at the client side as we already > have it in the stub generated and which works with asymmetric bindings ? >
I agree. Even though the generated client attaches the policy to various operations in populateAxisService, we still have to rebuild the policy from an external xml. Makes me wonder: why am I using wsdl2java already? Here's a way you can simplify things somewhat. Define a complete rampart config inside your client xml file (the policy is still needed). In my case: <ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy"> <ramp:user>...</ramp:user> <ramp:passwordCallbackClass>client.PWCBHandler</ramp:passwordCallbackClass> <ramp:userCertAlias>...</ramp:userCertAlias> <ramp:encryptionUser>...</ramp:encryptionUser> <ramp:encryptionCrypto> <ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin"> <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property> <ramp:property name="org.apache.ws.security.crypto.merlin.file">keystore</ramp:property> <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">...</ramp:property> </ramp:crypto> </ramp:encryptionCrypto> <ramp:signatureCrypto> <ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin"> <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property> <ramp:property name="org.apache.ws.security.crypto.merlin.file">keystore</ramp:property> <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">...</ramp:property> </ramp:crypto> </ramp:signatureCrypto> </ramp:RampartConfig> Then in your java code all you need to do is this: StAXOMBuilder builder = new StAXOMBuilder("axis_repo/policy-client.xml"); Policy policy = PolicyEngine.getPolicy(builder.getDocumentElement()); sc.getOptions().setProperty(RampartMessageData.KEY_RAMPART_POLICY, policy); I still wish I could avoid policy duplication on the client side. Ideally I would like to write a rampart.xml with no policy inside and assign that config to my generated service client. -- Philippe