Forum Discussion

Saur212_130858's avatar
Saur212_130858
Icon for Nimbostratus rankNimbostratus
Jul 29, 2013

Reading SOAP header through iRule

Team, Can anyone help me with configuring an iRule script to read a custom SOAP header in an incoming HTTP service request and make my own decision logic based on the content. I basically need to read through a collection SOAP header and scan individual elements in it. I am new to iRule and would appreciate some help on this. Thanks!

8 Replies

  • are these useful?

     

     

    XML Field Logger Using HTTP Commands

     

    https://devcentral.f5.com/wiki/iRules.XMLFieldLoggerUsingHTTPCommands.ashx

     

     

    XML

     

    https://devcentral.f5.com/wiki/irules.XML.ashx
  • Thank you. I will go through it.

     

    Btw, Is there any iRule emulator that I can use while am trying to play with iRule scripting? Since I have very limited knowledge on iRule it would be great to use any such tool.

     

    In my requirement I have SOAP header which is of the form (attached file).

     

    I want to extract values like value1 and value2. Appreciate any help.
  • Is there any iRule emulator that I can use while am trying to play with iRule scripting? Since I have very limited knowledge on iRule it would be great to use any such tool. usually i use bigip virtual edition to test. to send soap message, you know, we can use curl command.

     

     

    e.g.

     

    Test a SOAP web service using curl

     

    http://lancegatlin.org/tech/test-a-soap-web-service-using-curl
  • the bigip virtual edition you suggested if i understand correctly needs to install it on a vmware system, correct? I am in need of an emulator or something which i can run on a windows machine (like Win 7) and test my script against? Is that possible.

     

     

    Also if you can suggest how i can traverse through all child elements inside a SOAP header element it will be helpful to get me started since I couldn;t find documentation on traversing through child elements in an incoming soap header.

     

     

    Thanks.
  • the bigip virtual edition you suggested if i understand correctly needs to install it on a vmware system, correct?yes

    I am in need of an emulator or something which i can run on a windows machine (like Win 7) and test my script against? Is that possible. i am not sure but i think someone is able to run it on vmware workstation even it is not officially supported. 🙂

    Also if you can suggest how i can traverse through all child elements inside a SOAP header element it will be helpful to get me started since I couldn;t find documentation on traversing through child elements in an incoming soap header. i am not much familiar with xml. anyway, hope this is helpful more or less.

    e.g.

    [root@ve10:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
      if { [HTTP::method] eq "POST" }{
        set clength 0
        if {[HTTP::header exists "Content-Length"] && [HTTP::header Content-Length] <= 1048576}{
          set clength [HTTP::header Content-Length]
        } else {
          set clength 1048576
        }
        if { [info exists clength] && $clength > 0} {
          HTTP::collect $clength
        }
      }
    }
    when HTTP_REQUEST_DATA {
      set header1 [findstr [HTTP::payload] "mycustomheader1>" 16 "<"]
      set header2 [findstr [HTTP::payload] "mycustomheader2>" 16 "<"]
    
      foreach var {header1 header2}{
        if {[set $var] == "" }{
          set $var 
        }
      }
            log local0. "\[HTTP::payload\]: [HTTP::payload]"
      log local0. "header1: $header1 header2: $header2"
    }
    }
    
    [root@ve10:Active] config  cat /var/log/ltm
    Aug  2 15:15:47 local/tmm info tmm[5139]: Rule myrule : [HTTP::payload]: value1value2
    Aug  2 15:15:47 local/tmm info tmm[5139]: Rule myrule : header1: value1 header2: value2
    
  • what if the SOAP request is like this and I want to parse by looping through each of the and parse this into a TCL list, without using regex??

     

    value1 value2

     

    value3 value4

     

    value5 value6

     

     

  • facing issue with posting soap so removed the > & < tags

     

    mycustomheader mycustomheader1value1/mycustomheader1 mycustomheader2value2/mycustomheader2 /mycustomheader mycustomheader mycustomheader1value3/mycustomheader1 mycustomheader2value4/mycustomheader2 /mycustomheader mycustomheader mycustomheader1value5/mycustomheader1 mycustomheader2value6/mycustomheader2 /mycustomheader