Forum Discussion

Guillermo_Ferna's avatar
Guillermo_Ferna
Icon for Nimbostratus rankNimbostratus
Jun 15, 2015

Read xml and redirect traffic

Hi, somebody can help me, I need read the value of a error in xml code, and with this information makes a traffic redirection, there is a sample of the code:

 

soapenv:Body> error="0"><tx nbreq=1><req name=insert ver=7.0.11 state=undefined><ent name=Subscriber ns=policy><set><expr><attr name=AccountId><op value="="><value val=TestUser1Lab></value></op></attr></expr><expr><attr name=MSISDN><op value="="><value val=0057123456789></value></op></attr></expr><expr><attr name=IMSI><op value="="><value val=508414170000000></value></op></attr></expr><expr><attr name=BillingDay><op value="="><value val=1></value></op></attr></expr><expr><attr name=Entitlement><op value="="><value val="Mail Service Package"></value></op></attr></expr><expr><attr name=Custom1><op value="="><value val=postpaid></value></op></attr></expr></set><res <strong>error="0"</strong> affected="1"></ent></req></tx>

 

Is there any way to read the information marked in bold and store in a variable? Thanks for your comments

 

3 Replies

  • This may do the trick.. but not sure if it's exactly what you're after:

    when HTTP_REQUEST { 
    set xml_error "error=\"0\""
    }
    
    when HTTP_RESPONSE {
    if { ([HTTP::header value Content-Type] contains "text/html" )&& [info exists xml_error] } {
        << - re-direct - >>
    }
    }
    
  • You can use a stream profile with this type of irule :

    when HTTP_REQUEST {
        Disable the stream filter for all requests
       STREAM::disable
    }
    when HTTP_RESPONSE {  
        Check if response type is text  
        if { ([HTTP::header value Content-Type] contains "text/html" )
           Match an http://*example.com string and replace it with nothing yet
          STREAM::expression {&<\w* error=\"0\">&&}
           Enable the stream filter for this response only  
          STREAM::enable  
       }  
    }   
    when STREAM_MATCHED {  
        Check if the matched string meets some condition that can't easily be checked for using a single regex in STREAM::expression
       if {[STREAM::match] starts_with "
  • Hello, the question is because we are receiving traffic from several server that makes request to an appliaction, now the f5 must receive this traffic and develop a load balance based on conection numbers, but the problem begins when I got the answer from the application, this response is based on xml code, and we need read the error level value on the response for make a decision for redirect traffic to another pool member.

     

    can you help me?