I have read this posting:
002865 I am trying to do the same thing. With much help from Ulf I have gotten my web service running and using wss4j's UsernameToken.
Now I have the task of creating a bunch of mock clients that access the web service verifying my work before. This serves another purpose as we will have implemented what we know our customers will probably do.
Easiest implementation is to use java.net.URL to send the request and get the response. Very crude, but it works. That is one way.
More realistically, clients will not be done that way. What I would like to implement is a client that uses code generated by WSDL2Java based on our posted wsdl. This tool worked well and generated code. But how do I set the header username and password. The wss4j site suggests doing this:
Unfortunately the port._setProperty method does not appear to be available. I have looked everywhere, but it is not there. I cannot see how this would work anyway. This is all generated from Axis. Does Axis know how to build a WS Security header? It seems like it would need the wss4j API for that.
Also, I am not too keen on altering the
java code generated by WSDL2Java. It could be done. But if I regenerate the code, I have to reedit the generated code by hand. It seems like there should be a way to alter the header from the client. Or am I way off base and there is a better way to do this?
Is there a way to add a WS Security
SOAP header to a request in the client. Here is my code: