Hi Ruchitch, I'm using Axis 2.1.3 and Rampart 1.3. I changed my service code as shown below. However, I'm still getting the same exceptions. BTW, I got this code from http://wso2.org/files/rampart-ut-samples.zip and not from the Apache Rampart site. The Rampart distro from the offical site doesn't contain sample03 (it does but the service is a simple echo service). Am I accessing the MessageContext instance in the correct manner? Thanks again.
public String echo(String arg) { MessageContext msgCtx = MessageContext.getCurrentMessageContext(); Vector results = null; if ((results = (Vector) msgCtx .getProperty(WSHandlerConstants.RECV_RESULTS)) == null) { System.out.println("No security results!!"); throw new RuntimeException("No security results!!"); } else { System.out.println("Number of results: " + results.size()); for (int i = 0; i < results.size(); i++) { WSHandlerResult rResult = (WSHandlerResult) results.get(i); Vector wsSecEngineResults = rResult.getResults(); for (int j = 0; j < wsSecEngineResults.size(); j++) { WSSecurityEngineResult wser = (WSSecurityEngineResult) wsSecEngineResults.get(j); if (wser.getAction() == WSConstants.UT && wser.getPrincipal() != null) { //Extract the principal WSUsernameTokenPrincipal principal = (WSUsernameTokenPrincipal)wser.getPrincipal(); //Get user/pass String user = principal.getName(); String passwd = principal.getPassword(); //Authenticate if("sanjay".equals(user) && "wspwd".equals(passwd)) { //Authentication successful System.out.println("User was: " + user); return arg; } else { throw new RuntimeException("Authentication Faliure!!"); } } } } return arg; } } Regards Sanjay >-----Original Message----- >From: Ruchith Fernando [mailto:[EMAIL PROTECTED] >Sent: 17 January 2008 12:29 >To: rampart-dev@ws.apache.org >Subject: Re: Exception when attempting to obtain UserNameToken >information at the service. > >Hi Sanjay, > >Which versions of Axis2 and Rampart are you using? >Seems like the way you access the MessageContext instance is wrong. > >If you are using the latest 1.3 version, please use : > >MessageContext msgCtx = MessageContext.getCurrentMessageContext(); > >to obtain the message context within the "echo" method in the >service class. > >Thanks, >Ruchith >