Forum Discussion
Mohanad_313515
Apr 04, 2019Nimbostratus
irule to insert action parameter inside Content-Type header for xml request
Hello we have a lot of xml services using soap version 1.2, im facing issue regarding validate soap action header using xml profile. To summarize, while SOAP 1.1 would have these HTTP headers...
Kai_Wilke
Apr 04, 2019MVP
Hi Mohanad,
the iRule below should do the trick for your.
It uses the STREAM profile to search on POST-Request for the regex pattern:
[^<|\r\n|\n]*
If a match is found the
STREAM_MATCHED
event will be triggered to read (or even manipulate) the string value of the regex match.
The action value get then extracted and stored into the
$action_value
via the [URI::basename]
command.
The iRule will finally replace the
Content-Type
header of the ongoing HTTP request based on the just extracted action value...
when HTTP_REQUEST {
if { ( [HTTP::method] eq "POST" )
and ( [HTTP::path] ends_with "/Service.svc" ) } then {
set stream_action 1
STREAM::expression {@[^<|\r\n|\n]*@@}
STREAM::enable
} else {
set stream_action 0
STREAM::disable
}
}
when STREAM_MATCHED {
set stream_action 2
set action_value [URI::basename [STREAM::match]]
log local0.debug "Found the action = $action_value"
STREAM::replace
}
when HTTP_REQUEST_SEND {
clientside {
if { $stream_action == 0 } then {
Let the request pass...
} elseif { $stream_action == 1 } then {
HTTP::header insert "Transfer-Encoding" "chunked"
} else {
HTTP::header remove "Content-Type"
HTTP::header insert "Content-Type" "application/soap xml; charset=utf-8; action=http://tempuri.org/IACHService/$action_value"
HTTP::header insert "Transfer-Encoding" "chunked"
log local0.debug "New Header Value: [HTTP::header value "Content-Type"]"
}
}
}
Note: You need to assign the default STREAM profile to your virtual server.
Cheers, Kai
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