Basically I am trying to write the JAX-WS service side code as per the article link below.
Code in handleMessage for web service client ( complete code is in http://informatictips.blogspot.com/2013/09/using-message-handler-to-alter-soap.html )
SOAPElement usernameToken = security.addChildElement("UsernameToken", "wsse");
usernameToken.addAttribute(new QName("xmlns:wsu"), "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
SOAPElement username = usernameToken.addChildElement("Username", "wsse");
username.addTextNode("TestUser");
SOAPElement password = usernameToken.addChildElement("Password", "wsse");
password.setAttribute("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
password.addTextNode("TestPassword"); ```
Now how to write relevant server side code for below input soap xml
<s:header>
<wsse:security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:usernametoken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:username>TestUser</wsse:username>
<wsse:password type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">TestPassword</wsse:password>
</wsse:usernametoken>
</wsse:security>
</s:header>
I am able to write the code for server side handler code for validating the WebService -Security Headers for OASIS, PFB handlerMessage(.) method looks like.
Input XML
Valid request
Unauthorized Request