Forum Discussion
Extract Session ID from SOAP body using iRule
Hi Malcolm. I thought I replied to this earlier. Below is my solution for persistence based on SessionID:
when HTTP_REQUEST {
Capture sessionID from SOAP Request if exists log local0. "**** RTO Session Call ****** "set content_length [HTTP::header "Content-Length"]
log local0. "Content Len: $content_length "Check if $content_length is not set to 0 if { $content_length > 0} { HTTP::collect $content_length
}
} when HTTP_REQUEST_DATA {
set payload [HTTP::payload] set key ""
set ekey "" set keylen [string length $key]set pos [expr {$keylen + [string first $key $payload] } ] set epos [string first $ekey $payload $pos] set id [string range $payload $pos [expr {$epos -1}] ]
log local0. "SSES key: $key pos: $pos epos: $epos "if { $id == "" } then {
log local0. "Parsing on " set payload [HTTP::payload] set key "" set ekey "" set keylen [string length $key]
set pos [expr {$keylen + [string first $key $payload] } ] set epos [string first $ekey $payload $pos]
log local0. "SES key: $key pos: $pos epos: $epos " set id [string range $payload $pos [expr {$epos -1}] ]
} log local0. "FINAL SESSIONID: $id " Check if ID is presentif { $id != "" } then { Persist on the ID value for X seconds log local0. "Persist on SESSIONID (id): $id " persist uie $id 600
Check if the JSESSIONID cookie is present in the request and has a non-null value } elseif { [HTTP::cookie "JSESSIONID"] ne "" } then {
Persist on the JSESSIONID cookie value for X seconds
log local0. "Persist on cookie JSESSIONID "
persist uie [HTTP::cookie "JSESSIONID"] 600
} else { Cookie wasn't set or didn't have a value, so check for the session ID in the URI
set jsess [findstr [HTTP::uri] "JSESSIONID" 11 ";"]
if { $jsess != "" } {
Persist on the JSESSIONID URI value for X seconds
log local0. "Persist on URI JSESSIONID "
persist uie $jsess 600
}
} log local0. "**** END RTO Session Call ****** " }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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