Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Need to remove first UsernameToken header on XML document using XSLT

Can someone help me with an XSLT transformation where i want to remove the first wsse:Security header from my request message. I am not an XSLT expert, so i started playing around with XSLT code but no luck yet.

My input message Before transformation

<soapenv:Envelope xmlns:acc="http://wsdl/AccountManagerDocLiteralWrapped/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

   <soapenv:Header>

   <wsse:Security soapenv:actor="actor1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">

   <wsse:UsernameToken wsu:Id="UsernameToken-1436F53E829718B6F31400871123845250">

   <wsse:Username>user1</wsse:Username>

   <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>

   <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">TAOptcRrjG0vM85BrdbhPw==</wsse:Nonce>

   <wsu:Created>2014-05-23T18:52:03.845Z</wsu:Created>

   </wsse:UsernameToken>

   </wsse:Security>

   <wsse:Security soapenv:actor="actor2" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">

   <wsse:UsernameToken wsu:Id="UsernameToken-1436F53E829718B6F31400871123845250">

   <wsse:Username>user2</wsse:Username>

   <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>

   <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">TAOptcRrjG0vM85BrdbhPw==</wsse:Nonce>

   <wsu:Created>2014-05-23T18:52:03.845Z</wsu:Created>

   </wsse:UsernameToken>

   </wsse:Security>

   </soapenv:Header>

   <soapenv:Body>

      <acc:transfer>

         <acc:acctFrom>AC1</acc:acctFrom>

         <acc:acctTo>AC2</acc:acctTo>

         <acc:amount>9</acc:amount>

      </acc:transfer>

   </soapenv:Body>

</soapenv:Envelope>

Expected Output after Transformation

<soapenv:Envelope xmlns:acc="http://wsdl/AccountManagerDocLiteralWrapped/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

   <soapenv:Header>

   <wsse:Security soapenv:actor="actor2" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">

   <wsse:UsernameToken wsu:Id="UsernameToken-1436F53E829718B6F31400871123845250">

   <wsse:Username>user2</wsse:Username>

   <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>

   <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">TAOptcRrjG0vM85BrdbhPw==</wsse:Nonce>

   <wsu:Created>2014-05-23T18:52:03.845Z</wsu:Created>

   </wsse:UsernameToken>

   </wsse:Security>

   </soapenv:Header>

   <soapenv:Body>

      <acc:transfer>

         <acc:acctFrom>AC1</acc:acctFrom>

         <acc:acctTo>AC2</acc:acctTo>

         <acc:amount>9</acc:amount>

      </acc:transfer>

   </soapenv:Body>

</soapenv:Envelope>

Appreciate any help with this.

- dk

Former Member
Not what you were looking for? View more on this topic or Ask a question