title: Retrieve username from UsernameToken scenario in web service on WSO2 Application Server
body: <p>I have a WSO2 ESB WSDL based proxy service which is secured with UsernameToken scenario. This wrapper service is for an Axis2 back-end web service deployed as an .aar file in the WSO2 Application Server. What I want is to retrieve the username used for the authentication in the back-end service.</p>
  
  <p>I tried to get the username using the below Java code, but it always comes back <code>NULL</code>:</p>
  
  <pre><code>MessageContext msgContext = MessageContext.getCurrentMessageContext(); 
  String username = (String)msgContext.getProperty(RampartMessageData.USERNAME);
  </code></pre>
  
  <p>It seems that the <code>MessageContext</code> does not store the Rampart message data. Is there anything I can set in the WSO2 ESB to have that username be passed to the back-end service in the message context?</p>
  
  <p>Thank you!</p>