Forum Discussion

Sam_Parkes_1110's avatar
Sam_Parkes_1110
Icon for Nimbostratus rankNimbostratus
Nov 16, 2012

XML profile trouble

Hi - I am trying to get an iRule in place that routes traffic based on XML content. I've done this before and it works ok, but this XMl string I have this time contains a namespace (which I'm not sure I understand yet...)

 

XML string is attached to this topic - I've removed the main part of xml to keep it simple:(see attached)

 

I've created the following XML profile and assigned it to the VIP:

 

profile xml Kobra_User_ID_Check {

 

defaults from xml

 

namespace mappings none

 

xpath queries "//kr:userId"

 

}

 

 

and I have an iRule on the VIP that looks like this:

 

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 {([matchclass $XML::values($i) contains Kobra_migrated_users])} {

 

pool pool1

 

}

 

else {

 

pool pool2

 

}

 

}

 

}

 

 

Oh and a class/data group like this:

 

class Kobra_migrated_users {

 

"u94770"

 

}

 

 

Hopefully someone can help, please, I think its related to the namespace mappings and how they are referred to within the xml doc, but am stuck, I've tried various combinations, but its not even logging the entry into the ltm log.

 

 

Sam.

 

 

7 Replies

  • Hi Sam,

     

     

    What error(s) are you seeing? Can you try wrapping the variable in double quotes?

     

     

    if {([matchclass "$XML::values($i)" contains Kobra_migrated_users])} {

     

     

    or worst case:

     

     

    if {([matchclass \"$XML::values($i)\" contains Kobra_migrated_users])} {

     

     

    Aaron
  • Hi Aaron,

     

     

    Thanks - unfortunately this still does not work with double quotes or \"

     

     

    I dont see any errors at all, but the rule doesn't even log the $XML::queries($i) and $XML::values($i) to /var/log/ltm.

     

    I can see the XML profile is at least inspecting the XML document, as the statistics page shows that, but also logs an entry under "Documents with no matches" each time I try an POST the XML to the VIP.

     

     

    So it seems to me that the XPath query I have specified is not correctly configured, and I thought perhaps the namespace mapping was something to with it?

     

     

    Sam.
  • Hi Sam,

     

     

    Thanks for the update. Can you post your attachment on pastebin or another site like it? I couldn't download it.

     

     

    Thanks, Aaron
  • Hi Aaron,

     

    I think I've got this working now, all the same configuration as above apart from the XML profile which now looks like this:

     

     

    profile xml Kobra_User_ID_Check {

     

    defaults from xml

     

    namespace mappings {

     

    mapping prefix "kr"

     

    mapping namespace "http://kobra.kuoni.com/xml"

     

    }

     

    xpath queries "//kr:kobraRequest/*"

     

    }

     

     

    This now prints out the userId and password values.

     

     

    In order to help anyone else who may read this topic - I will try and upload an image of the xml string I'm sending to help.

     

     

    Thanks again for your help Aaron.

     

    Sam.