XML based content routing

Hi all We need a requirement to setup XML based content routing to the specific NODE. Eg: Incoming request taking place via XML format which contains the string “12345” it should be routed to NODE-1, if the XML request contains “67890”, it should be routed to NODE-2 (both Nodes 1 & 2 are in the same POOL) Appreciate your help on this. Ganesh

Here is the sample code which I have tried;

when XML_CONTENT_BASED_ROUTING {

for {set i 0} { $i < $XML_count } {incr i} {

if {($XML_queries($i) contains “”)} { if {($XML_values($i) contains “26002”)} { node 10.65.9.104 8081 } elseif {($XML_values($i) contains “26003”)} { node 10.65.9.178 8081 } } } }

It’d be easier to assist if you gave a sample of the XML input. Sometimes the hardest part of XMLCBR is getting the xpath just right.

Here is sample XML content: Content routing should be required for the string mentioned below: network-operator-code for example: network-operator-code=26002, it should be route to WEB1 else if should be route to WEB2..

XML Prefix:soapenv Name space: http://schemas.xmlsoap.org/wsdl/soap/envelope/

X-Path query://network-operator-code

30030 12345678 26002 MYS ABC TEST

Okay, try this:

XML profile configuration (namespace mapping is not required because the node you’re looking for is not behind a namespace)

ltm profile xml /Common/xml-test-2 {
    app-service none
    defaults-from /Common/xml
    multiple-query-matches disabled
    namespace-mappings none
    xpath-queries { //network-operator-code }
}

iRule:

when CLIENT_ACCEPTED {
    set default_pool [LB::server pool]
}
when XML_CONTENT_BASED_ROUTING {
    switch $XML_values(0) {
        "12345" {
            log local0. "send to node-1"
            node 10.70.0.2 80
        }
        "67890" {
            log local0. "send to node-2"
            node 10.70.0.3 80
        }
        default {
            log local0. "send to pool"
            pool $default_pool
        }
    }   
}