Applies To:

Show Versions Show Versions

Manual Chapter: Configuring XML Content-Based Routing
Manual Chapter
Table of Contents   |   << Previous Chapter

29 
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 can configure content-based routing by creating an XML profile and associating it with a virtual server. In the XML profile, you define the matching content to look for in the XML document. You specify how to route the traffic by writing simple iRulesTM. When the system discovers a match, it triggers an iRule event, and you can configure the system to route traffic to a virtual server, a pool, or a node. The implementation described in this chapter routes traffic to a pool.
Figure 29.1 shows a simple XML document that the system could use to perform content-based routing. It includes an element called FinanceObject used in the implementation described in this chapter.
<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/">
<eai:SiebelEmployeeDelete soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<FinanceObject xsi:type="xsd:string">Route to Financing</FinanceObject>
To implement content-based routing, you first need to create an XML profile. XML profiles specify the content to look for in XML documents. In the XML profile, you define XPath queries to locate items in an XML document.
1.
On the Main tab of the navigation pane, expand Local Traffic and point to Profiles, Services, and click the create icon () next to XML.
The New XML Profile screen opens.
2.
In the Name box, type a unique name for the XML profile, such as cbr_xml_profile.
3.
Check the Custom box on the right.
The Namespace Mappings and XPath Queries settings become available.
4.
If you want to reference XML elements with namespaces in XPath queries, from Namespace Mappings, select Specify.
The screen displays the Namespace Mappings List settings.
a)
For Prefix, type the namespace prefix.
b)
For Namespace, type the URL that the prefix is mapped to.
c)
Click Add to add the namespace to the Namespace Mappings List.
6.
To define the matching criteria in the XML document, from XPath Queries, select Specify.
The screen displays the XPath Queries settings.
a)
For XPath, type an XPath expression. For example, to look for an element called FinanceObject, type //FinanceObject. For additional details, see Writing XPath queries.
b)
Click Add.
The expression is added to the list. You can define up to three XPath queries.
8.
Click the Finished button.
The system creates the XML profile.
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.
Use wildcards as needed (use * for elements and namespaces); for example, //emp:employee/*.
Table 29.1 summarizes the syntax for XPath expressions.
Table 29.2 shows examples of XPath queries.
Selects all b elements no matter where they are in the document.
Selects any element in a namespace bound to prefix b, which is a child of the root element a.
Selects elements in the namespace of element c, which is bound to prefix b, and is a child of element a.
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.
1.
On the Main tab of the navigation pane, expand Local Traffic, point to Pools, and click the create icon () next to Pool List.
The New Pool screen opens.
Note: If the Create button is unavailable, your user role may not grant you permission to create a pool.
2.
In the Name box, type a name for the pool, such as finance_pool.
3.
For the New Members setting, add the pool members:
a)
Click the New Address option.
b)
In the Address box, type the IP address of the server in the pool.
c)
In the Service Port box, type 80, or select HTTP.
d)
Click Add.
4.
Click Finished.
The system creates 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.
Instead of creating a pool, you can alternatively create a node or a virtual server to route traffic to. Refer to the Configuration Guide for BIG-IP® Local Traffic ManagerTM for details on creating nodes and virtual servers.
You create iRules to automate traffic forwarding for XML content-based routing. When a match occurs, an iRule event is triggered, and the iRule directs the individual request to a pool, a node, or virtual server. This implementation targets a pool.
1.
On the Main tab of the navigation pane, expand Local Traffic, point to iRules, and click the create icon () next to iRule List.
The New iRule screen opens.
2.
In the Name box, type a 1- to 31-character name, such as XML_CBR_iRule.
3.
In the Definition box, type the syntax for the iRule using Tool Command Language (Tcl) syntax.
For complete and detailed information on iRules syntax, see the F5 Networks DevCentral web site, http://devcentral.f5.com.
4.
Click Finished.
Figure 29.2 shows an example 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.
Table 29.3 describes the Tcl variables in the example iRule.
1.
On the Main tab of the navigation pane, expand Local Traffic, point to Virtual Servers, and click the create icon () next to Virtual Server List.
The New Virtual Server screen opens.
2.
In the Name box, type a name for the virtual server, such as vs_cbr.
3.
For the Destination setting, verify that the Type of virtual server is Host, and in the Address box, type an IP address for the virtual server.
4.
From the Service Port list, select HTTP.
5.
From the Configuration list, select Advanced.
6.
From the HTTP Profile list, select http.
This assigns the default HTTP profile to the virtual server.
7.
From the XML profile list, select the XML profile you created, such as cbr_xml_profile.
8.
For the SNAT Pool setting, select Auto Map.
9.
In the Resources area, for iRules, in the Available list, select the name of the iRule that you previously created, such as XML_CBR_iRule, and move it to the Enabled list.
10.
If you created a second pool, for Default Pool, select the pool to use as the default pool.
11.
Click Finished.
The system creates the virtual server.
When traffic that is routed to the virtual server includes the FinanceObject element and causes a match, the system sends it to the pool called finance_pool. If traffic does not include the element and does not cause a match, the system sends the request to the default pool, if one is specified, or drops the request, if no default pool is specified.
1.
On the Main tab of the navigation pane, expand Overview and click Statistics.
The Local Traffic Statistics screen opens.
2.
For Statistics Type, select Profiles Summary.
3.
In the Global Profile Statistics area, next to XML, click View.
The system displays information about the number of XML documents that were inspected, the number of documents that had no matches, or that had one, two, or three matches, and the number of XML documents that were found to be malformed.
Note: The system first checks for a match, then checks for malformedness of XML content. So if the system detects a match, it stops checking, and may not detect any subsequent parts of the document that are malformed.
Table of Contents   |   << Previous Chapter

Was this resource helpful in solving your issue?




NOTE: Please do not provide personal information.



Incorrect answer. Please try again: Please enter the words to the right: Please enter the numbers you hear:

Additional Comments (optional)