Forum Discussion

Ketan_B_343278's avatar
Ketan_B_343278
Icon for Nimbostratus rankNimbostratus
Oct 09, 2018

irule for xml content based parsing

Hi,

 

I need help for creating an irule.

 

Requirement: 1. Content type should be content-type: text/xml 2. When a user hits a URL with request it should land the request on ABC servers, and when user hits a URL with request it should land the request on XYZ servers.

 

 

So when i say request what it means is user is sending some request in xml format and it contains . . . , so if the request is coming from this with this content then it should go to ABC server only.

 

 

i followed couple of blogs but i not sure if those are helpful or not.

 

https://devcentral.f5.com/questions/irule-for-handling-xml-and-html-requests-61135 https://devcentral.f5.com/wiki/iRules.XML_CONTENT_BASED_ROUTING.ashx

 

So can i achieve this with irule or any other methods i need to use? Not much familiar with irule, so suggestions are greatly appreciated here.

 

Thanks,

 

1 Reply

  • You need to apply an XML profile in which you specify the XPath that you are looking for, then use an iRule to perform the pool assignment based on that. The $XML_count, $XML_values etc are created by the XML profile and contain the details of the matched XML elements.

    Use this for guidance: https://support.f5.com/kb/en-us/products/big-ip_ltm/manuals/product/ltm-implementations-11-2-0/3.html

    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
        }
      }
    }