I am trying to dynamically modify XML data in SOAP requests to ASMX services.
I overrided GetWebRequest()
method in SoapHttpClientProtocol
class in order to read and modify XML data that the RequestStream
contains.
The problem is, the request seems to be empty, there is no data in it whatsoever. Is this because the SOAP data hasn't yet been generated and serialized or am I doing something wrong?
What you need is a SoapExtension
. You could hook into the SoapMessageStage.AfterSerialize
stage in ProcessMessage
to modify your soap message. I've done this in the past to add WSSE headers in situations where I couldn't add a dependency on Microsoft's WSE library (since it isn't available for Mono).
Complete tutorial here: http://msdn.microsoft.com/en-us/magazine/cc164007.aspx
GetWebRequest
is too early for your purpose, GetWebResponse
is too late.