Overriding HTTP Headers
Use southbound forward mapping to overwrite the HTTP headers of a facade operation request.
To overwrite the host, port, and URI and any other header fields, enable the southbound forward mapping for a target operation, as follows:
Procedure
| Parameter | Description |
|---|---|
| Mapping Name | Enter a name for the mapping. For example, pass-through-map. |
| Type | Select XSLT from the drop-down list. |
| New File | Select the XSLT file. For example, pass-through.xsl. |
| Existing Files | Select the XSLT file (pass-through.xsl) from the drop-down list, if the XSLT is located in the ASG_CONFIG_HOME/ASG_Project/xslt directory. |
| Response Type | Select Full from the drop-down list. |
Sample XSLT File
The following is an example XSLT to override the host, port, and URI :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:map="http://www.tibco.com/asg/mapping"
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:form="http://www.tibco.com/asg/functions/form"
xmlns:c="http://www.tibco.com/schemas/asg/context"
xmlns:h="http://www.tibco.com/asg/protocols/http"
xmlns:f="http://www.tibco.com/asg/content-types/form"
xmlns:codecs="http://www.tibco.com/asg/functions/codecs"
exclude-result-prefixes="xsl soap11 c h form codecs">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="no"/>
<xsl:variable name="cnRequestHref">
<xsl:value-of select="/transformation/cnRequest/@href"/>
</xsl:variable>
<xsl:variable name="context">
<c:context>
<xsl:for-each select="/transformation/context">
<xsl:copy-of select="document(@href)/c:context/*"/>
</xsl:for-each>
</c:context>
</xsl:variable>
<xsl:variable name="recdRequest">
<xsl:copy-of select="$context/c:context/c:entry[@key='asg:httpRequest']/h:request"/>
</xsl:variable>
<xsl:template match="/">
<map:mapping-result>
<map:context>
<c:context>
<xsl:for-each select="$recdRequest/h:request/h:header">
<xsl:variable name="hdr_name" select="@name"/>
<xsl:if test="lower-case($hdr_name)!='accept-encoding'">
<xsl:element name="h:override-header">
<xsl:attribute name="name"><xsl:value-of select="$hdr_name"/></xsl:attribute>
<xsl:value-of select="."/>
</xsl:element>
</xsl:if>
</xsl:for-each>
<h:override-header name="Accept-Encoding">identity</h:override-header>
<xsl:choose>
<xsl:when test="string-length($recdRequest/h:request/h:query-string)>0">
<h:override-URI><xsl:value-of select="concat($recdRequest/h:request/h:request-uri,'?',$recdRequest/h:request/h:query-string)"/></h:override-URI>
</xsl:when>
<xsl:otherwise>
<h:override-URI><xsl:value-of select="$recdRequest/h:request/h:request-uri"/></h:override-URI>
</xsl:otherwise>
</xsl:choose>
<h:override-method><xsl:value-of select="$recdRequest/h:request/h:method"/></h:override-method>
</c:context>
</map:context>
<map:payload-xml><root><xsl:value-of select="$recdRequest/h:request/h:body"/></root></map:payload-xml>
</map:mapping-result>
</xsl:template>
</xsl:stylesheet>
Copyright © Cloud Software Group, Inc. All rights reserved.
