DataPower

DataPower

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  XSLt question

    Posted Wed February 07, 2024 10:07 AM

    Hi,

    I have a requirement for routing to LBG based on HTTP request header. If http-request-header value is X route it to LBGX. If value is empty or null then route it to LBGY. Can anyone suggest how can we use xslt to achieve this



    ------------------------------
    N k
    ------------------------------


  • 2.  RE: XSLt question

    Posted Wed February 07, 2024 10:12 AM

    Simply retrieve the request header and check the value. If it is X then set the routing variable to the host name LBGX, if there is no value retrieved, set the routing variable to the host name LBGY.

    Both LBGX and LBGY must be configured in the XML Manager that the service is using.



    ------------------------------
    Charlie Sumner
    ------------------------------



  • 3.  RE: XSLt question

    Posted Wed February 07, 2024 10:32 AM

    Thanks for your response Charlie. Can you let me know how to implement the logic in xslt to check if no value is retrieved? Also can we directly define the LBG name in xslt?



    ------------------------------
    N k
    ------------------------------



  • 4.  RE: XSLt question

    Posted Thu February 08, 2024 10:32 AM

    If you just have two LBGs, please use XSL When and Otherwise . But if you think that the possible values of LBGs might increase in future, You can use the Key Value pair combination to match and retrieve from the header. Also, you need to add all the LBGs in the XML manager of the service.

    The code looks something like the below

    Key Value Pair:

    <RoutingURL>
            <LBG name="X">LBGX</LBG>
            <LBG name="Y">LBGY</LBG>
            <LBG name="Z">LBGZ</LBG>
    </RoutingURL>

    <xsl:value-of select ="RoutingURL/LBG[@name="$headerValue"]/text()  "/>



    ------------------------------
    R K
    ------------------------------



  • 5.  RE: XSLt question

    Posted Thu February 08, 2024 09:12 AM

    Hi:

    You have to do these steps to achieve your requirement:

    1. In the XML Manager assigned to your MPG, you must add the LBG (nameofloadbalancergroup) in Load Balancer Group in Main tab.
    2. Use these code in your XSL in order to achieve your requirement
                  
                    <xsl:choose>
                        <xsl:when test="dp:request-header('headerName') = 'xyz'">
                            <dp:set-variable name="'var://service/routing-url'" value="'http://nameofloadbalancergroup'"/>
                        </xsl:when>
                        <xsl:otherwhise">
                            <dp:set-variable name="'var://service/routing-url'" value="'http://nameofanotherloadbalancergroup'"/>
                        </xsl:otherwhise>
                    </xsl:choose>


    ------------------------------
    David Bonilla
    ------------------------------