Applies To:
Show VersionsBIG-IP AAM
- 13.1.5, 13.1.4, 13.1.3, 13.1.1, 13.1.0
BIG-IP APM
- 13.1.5, 13.1.4, 13.1.3, 13.1.1, 13.1.0
BIG-IP Link Controller
- 13.1.5, 13.1.4, 13.1.3, 13.1.1, 13.1.0
BIG-IP Analytics
- 13.1.5, 13.1.4, 13.1.3, 13.1.1, 13.1.0
BIG-IP LTM
- 13.1.5, 13.1.4, 13.1.3, 13.1.1, 13.1.0
BIG-IP AFM
- 13.1.5, 13.1.4, 13.1.3, 13.1.1, 13.1.0
BIG-IP PEM
- 13.1.5, 13.1.4, 13.1.3, 13.1.1, 13.1.0
BIG-IP DNS
- 13.1.5, 13.1.4, 13.1.3, 13.1.1, 13.1.0
BIG-IP ASM
- 13.1.5, 13.1.4, 13.1.3, 13.1.1, 13.1.0
Overview: XML content-based routing
You can use the BIG-IP® system to perform XML content-based routing whereby the system routes requests to an appropriate pool, pool member, or virtual server based on specific content in an XML document. For example, if your company transfers information in XML format, you could use this feature to examine the XML content with the intent to route the information to the appropriate department.
You configure content-based routing by creating an XML profile and associating it with a virtual server. In the XML profile, define the matching content to look for in the XML document. Next, specify how to route the traffic to a pool by writing simple iRules®. When the system discovers a match, it triggers an iRule event, and then you can configure the system to route traffic to a virtual server, a pool, or a node. You can allow multiple query matches, if needed.
This example shows a simple XML document that the system could use to perform content-based routing. It includes an element called FinanceObject used in this implementation.
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:eai="http://192.168.149.250/eai_enu/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> <soapenv:Header/> <soapenv:Body> <eai:SiebelEmployeeDelete soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <FinanceObject xsi:type="xsd:string">Route to Financing</FinanceObject> <SiebelMessage xsi:type="ns:ListOfEmployeeInterfaceTopElmt" xmlns:ns="http://www.siebel.com/xml"> <ListOfEmployeeInterface xsi:type="ns:ListOfEmployeeInterface"> <SecretKey>123456789</SecretKey> <Employee>John</Employee> <Title>CEO</Title> </ListOfEmployeeInterface> </SiebelMessage> </eai:SiebelEmployeeDelete> </soapenv:Body> </soapenv:Envelope>
Task summary
You can perform tasks to enable XML content-based routing whereby the system routes requests to an appropriate pool, pool member, or virtual server based on specific content in an XML document.
Task list
Creating a custom XML profile
Writing XPath queries
You can write up to three XPath queries to define the content that you are looking for in XML documents. When writing XPath queries, you use a subset of the XPath syntax described in the XML Path Language (XPath) standard at http://www.w3.org/TR/xpath.
These are the rules for writing XPath queries for XML content-based routing.
- Express the queries in abbreviated form.
- Map all prefixes to namespaces.
- Use only ASCII characters in queries.
- Write queries to match elements and attributes.
- Use wildcards as needed for elements and namespaces; for example, //emp:employee/*.
- Do not use predicates in queries.
Syntax for XPath expressions
This table shows the syntax to use for XPath expressions.
Expression | Description |
---|---|
Nodename | Selects all child nodes of the named node. |
@Attname | Selects all attribute nodes of the named node. |
/ | Indicates XPath step. |
// | Selects nodes that match the selection no matter where they are in the document. |
XPath query examples
This table shows examples of XPath queries.
Query | Description |
---|---|
/a | Selects the root element a. |
//b | Selects all b elements wherever they appear in the document. |
/a/b:* | Selects any element in a namespace bound to prefix b, which is a child of the root element a. |
//a/b:c | Selects elements in the namespace of element c, which is bound to prefix b, and is a child of element a. |
Creating a pool to manage HTTP traffic
For implementing content-based routing, you can create one or more pools that contain the servers where you want the system to send the traffic. You write an iRule to route the traffic to the pool.
If you want to specify a default pool to which to send traffic when it does not match the content you are looking for, repeat the procedure to create a second pool. You specify the default pool in the virtual server. Alternatively, you can create a node or a virtual server to route traffic to instead of creating a pool.
Creating an iRule
Examples of iRules for XML content-based routing
This example shows an iRule that queries for an element called FinanceObject in XML content and if a match is found, an iRule event is triggered. The system populates the values of the Tcl variables ($XML_count, $XML_queries, and $XML_values). Then the system routes traffic to a pool called finance_pool.
when XML_CONTENT_BASED_ROUTING { for {set i 0} { $i < $XML_count } {incr i} { log local0. $XML_queries($i) log local0. $XML_values($i) if {($XML_queries($i) contains "FinanceObject")} { pool finance_pool } } }
This is another example of XML content-based routing. It shows routing by bank name and by price.
when XML_CONTENT_BASED_ROUTING { for {set i 0} { $i < $XML_count } {incr i} { # routing by BANK_NAME if {($XML_queries($i) contains "BANK_NAME")} { if {($XML_values($i) contains "InternationalBank")} { pool pool1 } elseif {($XML_values($i) contains "Hapoalim")} { pool pool2 } else { pool pool3 } } # routing by PRICE if {($XML_queries($i) contains "PRICE")} { if {($XML_values($i) > 50)} { pool pool1 } else { pool pool2 } } # end for } }
Tcl variables in iRules for XML routing
This table lists and describes the Tcl variables in the sample iRule.
Tcl variable | Description |
---|---|
$XML_count | Shows the number of matching queries. |
$XML_queries | Contains an array of the matching query names. |
$XML_values | Holds the values of the matching elements. |