I used Axis2 WSDL2Java to generate a client stub, which works just fine and dandy against an unsecured version of the service.
However, I need to use simple UsernameToken for a "secured" version.
I have followed the rampart samples and tried to accomplish this both via a config file:
<module ref="rampart" />
<parameter name="OutflowSecurity">
<action>
<items>UsernameToken</items>
<user>userblah</user>
<passwordCallbackClass>client.PWCallbackHandler</passwordCallbackClass>
</action>
</parameter>
...as well as through an OutflowSecurity (deprecated) object:
OutflowConfiguration ofc = new OutflowConfiguration();
ofc.setActionItems("UsernameToken");
ofc.setUser("userblah");
options.setProperty(WSSHandlerConstants.OUTFLOW_SECURITY, ofc.getProperty());
...and additionally through the following VERY SIMPLE code:
ServiceClient sc = <stub>._getServiceClient();
sc.engageModule("rampart");
Options o = sc.getOptions();
o.setUsername("userblah");
o.setPassword("userpass");
I noticed I was getting "MustUnderstand header not processed" errors, so...
When I serialize my SOAPEnvelope before sending the message off (in the generated stub code), I notice that the
soap envelope does not contain an <env:Header> element.... it's totally missing.
Furthermore, if I put a system.out in my password callback handler, the code executes. Why?
There is one line of interest in the generated stub:
_serviceClient.addSoapHeaders(env);
Serializing the envelope before/after that line yields identical, headerless envelopes, yet debug dissection of the _serviceClient object reveals that it contains the appropriate action items, username, password, etc. Furthermore, the rampart object is correctly engaging according to console output, and I get no errors from Axis2 or Rampart (other than the MustUnderstand from the server).
Why is the service client not adding the appropriate soap header??? This should be so simple!
Please, any help is appreciated, I've spent nearly two full days trying all sorts of things, and I'm tired of searching Google, to no avail.
What could I be doing wrong?
I'm using Axis2 1.4 w/ Rampart 1.4
-Chris