0

I am having a WS Proxy in Datapower . Both the client and the backends are HTTP . My request contains a soap header that has values like : wsa:Action wsa:MessageID wsa:ReplyTo timestamp

The backend doesnt require all these values , so they are stripped of before sending a cnverted request to the backend and obviously these are not there in the response which I get back from backend. Now when I send a response back to the client from Datapower , I need all these values back in the response soap headers . A

newly created timestamp which expires after 5 mins . Action MessageID ReplyTo

Is there any way to put them back. I dont want to do it from xslt , as I beleive there is some inbuilt support from Datapower to handle this .

user1496397
  • 21
  • 1
  • 4

2 Answers2

0

I would just store the entire SOAP-header node-set in a context variable and replace it in the response rule. Unless, of course the back-end adds or modifies specific values. In that case, you can pick and choose what to restore.

bendigi
  • 590
  • 6
  • 15
0

Please find below code tp remove header and to move it to context variable . Further you can use that context variable values to place it back.

XSl1 : To save username and password into context variable`

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:dp="http://www.datapower.com/extensions"
xmlns:dpconfig="http://www.datapower.com/param/config" 
extension-element-prefixes="dp date dpconfig" exclude-result-prefixes=" dp dpconfig ">
<xsl:template match="/">
 <xsl:variable name = "User">
 <xsl:value-of select="/*[local-name()='Envelope']/*[local-name()='Header']/*[local-name()='Security']/*[local-name()='UsernameToken']/*[local-name()='Username']/text()"/>


</xsl:variable>
<xsl:variable name = "PWD">
<xsl:value-of select="/*[local-name()='Envelope']/*[local-name()='Header']/*[local-name()='Security']/*[local-name()='UsernameToken']/*[local-name()='Password']/text()"/>
</xsl:variable> 
<xsl:message dp:priority="debug">
  User name : <xsl:value-of select="$User"/>
 <xsl:message dp:priority="debug">
  Password : <xsl:value-of select="$PWD"/>
 </xsl:message>
<dp:set-variable name="'var://context/Test/User'" value ="string($User)"/>
 <dp:set-variable name="'var://context/Test/Pws'" value ="string($PWD)"/>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
<soapenv:Header>
</soapenv:Header>           
    <soapenv:Body>
<xsl:copy-of select="/*[local-name()='Envelope']/*[local-name()='Body']/*" />
</soapenv:Body>
</soapenv:Envelope>
 </xsl:template>
</xsl:stylesheet>

XSl2 :To add back the Username and Password back into SOAP .

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:dpconfig="http://www.datapower.com/param/config" 
extension-element-prefixes="dp dpconfig soapenv" exclude-result-prefixes="dp dpconfig">
    <xsl:template match="@*|node()">
<xsl:copy>
 <xsl:apply-templates select="@*|node()"/>
</xsl:copy>  
</xsl:template>
  <xsl:template match = "*[local-name() = 'Header']">


<soapenv:Header xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soap:appid xmlns:soap="http://na.az.com/soaplatform">?</soap:appid>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>
<xsl:value-of select="dp:variable('var://context/Test/User')"/>
</wsse:Username>
<wsse:Password>
<xsl:value-of select="dp:variable('var://context/Test/Pws')"/>
</wsse:Password>
    </wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
</xsl:template>
</xsl:stylesheet>
sreevathsa a
  • 149
  • 13