You should actually be able to get away with using a STREAM profile here. It'll be much faster than buffering request payload and you can also get rid of the regex.
when HTTP_REQUEST {
if { [HTTP::header Content-Type] contains "soap" } {
STREAM::expression {@:i@:xsi@}
STREAM::enable
} else {
STREAM::disable
}
}
when HTTP_RESPONSE {
STREAM::disable
}
One important caveat of using STREAM in an HTTP_REQUEST is that you need to force HTTP chunking. Create a new HTTP profile and set Request Chunking to "Rechunk". Add this HTTP profile and a generic empty STREAM profile to the VIP, along with this iRule.