Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved


Chapter 8 Routing : Routing Use Case using XSLT

Routing Use Case using XSLT
This section describes the GetLocation sample shipped with the TIBCO API Exchange Gateway product to illustrate the configuration steps required for routing. Refer to the GetLocation example in the ASG_HOME/examples directory.
Sample Name
GetLocation
Description
The GetLocation example illustrates how to use a routing key to route the facade request to a different target operation or target operation group. The routing key is derived from the telephone number specified in the address element of the request. The target operation or target operation group must be configured in the Config UI.
For example,
If the value of the address element is specified as "tel:+498948956000", the opCoId derived using the substring function (substring($address,6,2)) from the address element is 49.The routing key is populated based on the opCoId as 49. See Configuration for the routing configuration.
Sample Location
ASG_CONFIG_HOME/GetLocation
 
Configuration
Perform the following steps for the routing configuration:
 
Task A Define a Transformation File
Refer to the Sample XSLT File sample file to define a transformation file. This XSLT file shows that the routing key is derived based on the value of the address element of the request message. The address element contains a telephone number. You can edit the file, as required.
Sample XSLT File Location
ASG_CONFIG_HOME/GetLocation/xslt/operations/parse_getLocation.xsl
Sample XSLT File

 
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:loc = "urn:oma:wsdl:pxprof:terminallocation:1.0:interface:local">
<xsl:template match="/">
 
<xsl:variable name="nbRequestHref">
<xsl:value-of select="/transformation/nbRequest/@href"/>
</xsl:variable>
<xsl:variable name="nbRequest">
<xsl:copy-of select="document($nbRequestHref)/soap:Envelope/soap:Body/*"/>
</xsl:variable>
 
<output>
<xsl:variable name="address">
<xsl:value-of select="$nbRequest/loc:getLocation/loc:address"/>
</xsl:variable>
<xsl:variable name="partner">
<xsl:value-of select="$nbRequest/loc:getLocation/loc:requester"/>
</xsl:variable>
<xsl:variable name="opCoId">
<xsl:value-of select="substring($address,6,2)"/>
</xsl:variable>
<requester><xsl:value-of select="$partner"/></requester>
<serviceInterfaceVersion></serviceInterfaceVersion>
<referenceId></referenceId>
<serviceId></serviceId>
<timestamp></timestamp>
<correlationId></correlationId>
<identityId></identityId>
<opCoId><xsl:value-of select="$opCoId"/></opCoId>
<partnerId><xsl:value-of select="$partner"/></partnerId>
<routingKey>
<xsl:choose>
<xsl:when test="$opCoId != ''"><xsl:value-of select="$opCoId"/></xsl:when>
<xsl:otherwise>undefined</xsl:otherwise>
</xsl:choose>
</routingKey>
<address><xsl:value-of select="$address"/></address>
</output>
</xsl:template>
</xsl:stylesheet>

 
Task B Upload the Transformation File
To upload the parse_getLocation.xsl transformation file, do the following steps:
1.
2.
3.
Select Getlocation under Projects.
4.
Click the ROUTING tab on upper left.
5.
Click the Facade Operations tab.
6.
Expand the getLocationBW operation.
7.
Make sure that the operations/parse_getLocation.xsl file is populated in the ProcessBody Transform field. If it is not selected, select it from the drop-down list.
8.
Task C Routing Configuration
Configure a routing key for the getLocationBW operation to route the request to the http.getLocation target operation, as follows:
1.
On ROUTING tab, click the Routing tab on the top menu.
2.
Click the Add Property to add a new routing configuration.
3.
Select getLocationBW from the drop-down list.
Select Target Operation from the drop-down list.
Enter 49 as the routing key.
Select the target operation as http.getLocation from the drop-down list. The http.getLocation target operation is defined in the Target Operations tab.
4.
The routing configuration for the GetLocation example demonstrates the getLocationBW operation. For the getLocationBW operation request, if the routing key is populated as 49 from the data content of the incoming request message, the request is routed to the http.getLocation target operation. Similarly, you can define additional routing configuration to route the request to a different target operation for a different routing key.

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved