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=
If 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
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?
Deb’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
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?
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 ‘<’]”
}
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/
You’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
Actually 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
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 <]
}
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.
1.) There’s no reason to split this into two rules. It’s quite normal to have the request and response portion in the same iRule.
2.) The error you’re seeing is because you need to supply an integer value for the HTTP::collect command. It looks like the interpreter is being picky about the fact that you’re supplying a substitution that you’re hoping turns out to be an integer, not a raw integer. Try placing an integer value there instead. I’ll look into whether we can make this a little more tolerant.
Colin
Colin,
I am not sure what you mean by plugging an integer value in.
I split the rule into two rules to test them. For this block I get the TCL error.
when HTTP_RESPONSE {
collect the payload containing the REPLY 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 <]
}
You need to set a value for the collect length, and there most likely is not a Content-Length header in the chunked response (typical for XML payloads since they are mostly dynamic). More on that later, though, as I think we need to more clearly define the problem we are trying to solve -- if the desired persistence data is in the response rather than the request, you will need to change the logic a bit.
I assumed the data was in the request, but now it’s unclear.
Is the data you want to persist on in the response only?
/deb
Initially I thought the soap header was generated on the client side.
What is happening is the client generates an authentication attempt. The reply from the server contains the soap header value I want to set persistence on. The client then passes a data request with the same soap header.
The bigip is not sending that request back to the same node it authenticated to so the server that gets the request sees it as an unauthenticated request.
Deb,
I had someone else who is working on this issue point out a post which has kind of what I think I am looking for.
Dennypayne posted an Irule that sets persistence after the client connection is accepted. It is using a uri instead of a header value, but I figure I could adapt it using the findstr command. What do you think?
Ah, got it.
Then we need to know the name of the response header and the value contained in it to adjust the iRule to write a persistence table entry in the response event.
/deb
(didn’t see your other post)
This thread has response event logic similar to what you’d need to add to the request bit we’ve already worked out.
DevCentral - An F5 Technical Community (Click here
So something like this, replacing/adjusting the findstr command in HTTP_RESPONSE to match your situation:
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 "<"
follow existing persistence record or create a new one
persist uie [findstr [HTTP::payload] xmlns:soapenc= 58 <]
log local0. "Request SessionID is: >[findstr [HTTP::payload] xmlns:soapenc= 58 <]<"
}
when HTTP_RESPONSE {
set SessionId [findstr [HTTP::header SOAPheader] "xmlns:soapenc=" 58 <]
log local0. "Response SessionId is: >$SessionId<"
if { $SessionId != "" }{ persist add uie $SessionId }
}
I grabbed Dennypayne’s Irule and updated it with the findstr that was working earlier. I am getting three errors when I try to save the rule.
when CLIENT_ACCEPTED {
set add_persist 1
when HTTP_RESPONSE {
set uid [findstr [HTTP::payload] xmlns:soapenc= 58 <] “uid=” 5 “&”]
if { $uid != “” and $add_persist} {
log local0. “Adding persist value to table: $uid”
persist add uie $uid
set add_persist 0
}
when HTTP_REQUEST {
set fulluri [HTTP::uri]
set uid [findstr [HTTP::payload] xmlns:soapenc= 58 <] “uid=” 5 “&”]
if { $uid != “” } {
log local0. “Using persist value uid: $uid | $fulluri”
persist uie $uid
} else {
log local0. “No uid found in HTTP REQUEST | $fulluri”
}
}
Let me give that a shot. Thanks Deb