on 05-23-2014 9:30 PM
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
Hi Deepthi,
Please give the following snippet a try, it should ignore the first occurence of wsse:Security for the output (the first template is used to copy everything into the output, the second template is overruling the first template for the first occurence of wsse:Security and creates an empty output for it):
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="wsse:Security[1]"/>
</xsl:stylesheet>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.