Hi Daniel,

I take advantage of WSS4J to add UsernameToken to the SOAPEnvelope.
Some sample codes:

Document domDoc = Axis2Util.getDocumentFromSOAPEnvelope(envelope);
// Add the UserNameToken.
WSSAddUsernameToken builder = new WSSAddUsernameToken("", false);
if (token.isDigested()) {
        builder.setPasswordType(WSConstants.PASSWORD_DIGEST);
} else {
        builder.setPasswordType(WSConstants.PASSWORD_TEXT);
}

builder.build(domDoc, token.getUsername(), token.getPassword());
Element header = (Element)
(domDoc.getElementsByTagName("SOAP-ENV:Header").item(0));
                
//SOAPHeader header = Axis2Util.getSOAPFactory(envelope);
//SOAPFactory factory = Axis2Util.getSOAPFactory(envelope);
                
OMElement headerElm = (OMElement) (Axis2Util.toOM(header));
envelope.getBody().insertSiblingBefore(headerElm);


These are only some experimental codes.
I assume the SOAPEnvelope has been constructed. What these code
snippet is more of a handler. There may be other ways to do it. As
Ruchith said, you can also take advantage of Axis2 security module.

Regards,
Xinjun


On 4/6/06, Daniel Destro <[EMAIL PROTECTED]> wrote:
> Hi Xinjun,
>
> As I can see you are trying to add some Security to your Web Services,
> right?
>
> Are you doing a User Authentication / Authorization using this
> UsernameToken?
>
> I need to do that!
>
> How do add UsernameToken into to the SOAP request and how do u read /
> validate UsernameToken from the SOAP request (server-side) ???
>
> Thanks
> Daniel
>

Reply via email to