Forum Discussion
Chris_Schaerli_
Nimbostratus
Jun 18, 2007Tracking session in soap header?
I have been going though the board looking for something to help me with a session persistence issue. I have some transactions I need to set persistence on and I can’t use source IP or cookie. The only thing I have been able to find is a value in the soap header that is unique per session. I have not been able to figure out how to pull that out.
Can anyone suggest a place to start? Here is a snip of the soap header. I need to track on the “soapenc” value.
Jz8rPz8/eAVeJT8/Pz8/KT8/PzA/BD8/Pxd4Pz9LPxg/P2M/Pz8/Pz8/P1I/LT8rP18=
25 Replies
- Deb_Allen_18Historic F5 AccountIf the value will be in each request in the same general format, you could use a rule like this one:
when HTTP_REQUEST { collect the payload containing the POST data HTTP::collect [HTTP::header Content-Length] } when HTTP_REQUEST_DATA { persist on data from 59th character following 'xmlns:soapenc=' up to "<" and follow existing persistence record or create a new one persist uie [findstr [HTTP::payload] "xmlns:soapenc=" 58 "<" }
HTH
/deb - Chris_Schaerli_
Nimbostratus
Thanks for the suggestion. I gave it a shot and it is still not working. Is there a way to output the value that the iRule is grabbing to a log? - Colin_Walker_12Historic F5 AccountDeb's rule is close, but missing a closing bracket on the last functional line.
when HTTP_REQUEST { collect the payload containing the POST data HTTP::collect [HTTP::header Content-Length] } when HTTP_REQUEST_DATA { persist on data from 59th character following 'xmlns:soapenc=' up to "<" and follow existing persistence record or create a new one persist uie [findstr [HTTP::payload] "xmlns:soapenc=" 58 "<"] }
If you haven't tried it with that closing bracket, I'd give that a shot. If you have and it's still not working, then yes, you can absolutely output what's being returned to the log file. You'd do so like:when HTTP_REQUEST { collect the payload containing the POST data HTTP::collect [HTTP::header Content-Length] } when HTTP_REQUEST_DATA { persist on data from 59th character following 'xmlns:soapenc=' up to "<" and follow existing persistence record or create a new one persist uie [findstr [HTTP::payload] "xmlns:soapenc=" 58 "<"] log local0. "[findstr [HTTP::payload] 'xmlns:soapenc=' 58 '<']" }
HTH,
Colin - Chris_Schaerli_
Nimbostratus
Colin,
Thanks for the logging. One question, I noticed that Deb used double quotes around the search string and you have single quotes around them. Are the single and double quotes interchangeable? - Chris_Schaerli_
Nimbostratus
The logging did help. I am getting this error "HTTP_REQUEST_DATA - invalid command name findstr" then I see the SOAP message body. So I am guessing the search is not working exactly right.
Here is what the rule looks like. I did try single and double quotes.
when HTTP_REQUEST {
collect the payload containing the POST data
HTTP::collect [HTTP::header Content-Length]
}
when HTTP_REQUEST_DATA {
look for persistence data beginning the 59th character following the 'xmlns:soapenc=' string & ending @ "<" char
and follow existing persistence record or create a new one
persist uie [findstr [HTTP::payload] 'xmlns:soapenc=' 58 '<']
log local0. "[findstr[HTTP::payload] 'xmlns:soapenc=' 58 '<']"
} - Chris_Schaerli_
Nimbostratus
I used the Irules editor as well and it didn't have any issues saving.
I setup the rule on a hash profile. When a user hits the VIP I see the error three times.
Here is the full error from the log.
TCL error: Rule FOO_persist HTTP_REQUEST_DATA - invalid command name findstr?xml version=1.0 encoding=UTF-8?soapenv:Envelope
xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/ xmlns:xsd=http://www.w3.org/2001/XMLSchema
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instancesoapenv:Headerns1:gw_auth_prop soapenv:actor=http://schemas.xmlsoap.org/soap/actor/next
soapenv:mustUnderstand=0
xsi:type=soapenc:string xmlns:ns1=http://www.FOO.com/soap
xmlns:soapenc=http://schemas.xmlsoap.org/soap/encoding/Pz8xLz8aRT87P0c/Pz8VOVMpP1A/QE4/LT8GdUc/Zj8VBj8/Pz9iP31BHyxePz8/P2g=/
ns1:gw_auth_prop/soapenv:Headersoapenv:Bodyns2:viewUserAndRenderWithTemplateByName
soapenv:encodingStyle=http://schemas.xmlsoap.org/soap/encoding/ xmlns:ns2=http://api.webservices.cc.guidewire.com/userName xsi:type=soapenc:string
xmlns:soapenc=http://schemas.xmlsoap.org/soap/encoding/su/userNamegetActivities href=id0/ - Deb_Allen_18Historic F5 AccountYou're just missing the whitespace after the findstr command in your log line.
the Big Clue is the name of the command reported as invalid ("findstr?xml version=1.0 encoding=UTF-8?soapenv:Envelope...")
Single quotes or double don't matter, but using single quotes for the log lines avoids collision with enclosing double quotes.
No quotes at all around the findstr command or it's parameters should work fine:log local0. [findstr [HTTP::payload] xmlns:soapenc= 58 <]
/deb - Deb_Allen_18Historic F5 AccountActually was just testing findstr for another iRule and discovered that single quotes in the findstr command are taken literally, rather than as delimiters, meaning that the match will fail if the search string is delimited with single quotes, and the match will extend to the end of the string if the termination character is delimited with single quotes (neither being the intended result.)
No quotes does work fine. If either the term char or the search string contain a double quote character, it can be escaped with a backslash immediately preceding the " character, or by enclosing the entire string in curly braces {}.
Wiki page has been updated to reflect these details, sorry for any confusion.
/deb - Chris_Schaerli_
Nimbostratus
I was able to get the session value for the request, but now I also need to get the data for the response post.
I tried duplicating the rule, with http_Request instead of http_response and I am getting this error.
TCL error: Rule claimcenter_persist HTTP_RESPONSE - expected integer but got Illegal argument. Invalid integer value line 1 invoked from within HTTP::collect [HTTP::header Content-Length]
Here is what I have now for the rule.
when HTTP_REQUEST {
collect the payload containing the POST data
HTTP::collect [HTTP::header Content-Length]
}
when HTTP_REQUEST_DATA {
look for persistence data beginning the 59th character following the 'xmlns:soapenc=' string & ending @ "<" char
and follow existing persistence record or create a new one
persist uie [findstr [HTTP::payload] xmlns:soapenc= 58 <]
log local0. [findstr [HTTP::payload] xmlns:soapenc= 58 <]
}
when HTTP_RESPONSE {
collect the payload containing the POST data
HTTP::collect [HTTP::header Content-Length]
}
when HTTP_RESPONSE_DATA {
look for persistence data beginning the 59th character following the 'xmlns:soapenc=' string & ending @ "<" char
and follow existing persistence record or create a new one
persist uie [findstr [HTTP::payload] xmlns:soapenc= 58 <]
log local0. [findstr [HTTP::payload] xmlns:soapenc= 58 <]
} - Chris_Schaerli_
Nimbostratus
Should I split this into two different IRules one for request and the other for response?
BTW the logging really helps with seeing what the rule is doing.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
