This is a subset of my Web Service class which intercepts the SOAP message and stores it into the HTTPContext so I can access it from my application.
Public Overrides Sub ProcessMessage(ByVal message As SoapMessage)
Dim loStreamReader As StreamReader = Nothing
Dim lcString As String = ""
Select Case message.Stage
Case SoapMessageStage.BeforeSerialize
Case SoapMessageStage.AfterSerialize
WriteOutput(message)
Case SoapMessageStage.BeforeDeserialize
WriteInput(message)
System.Web.HttpContext.Current.Request.InputStream.Position = 0
loStreamReader = New StreamReader(System.Web.HttpContext.Current.Request.InputStream)
lcString = loStreamReader.ReadToEnd()
System.Web.HttpContext.Current.Items("HTTPInputStream") = lcString
Case SoapMessageStage.AfterDeserialize
End Select
End Sub
So, basically, later on in the application, I can know what was received in the SOAP envelope. Now, we need to do the same thing for the response. This is the difficult part. Has anyone done that before? Basically, I need to know what was sent to the client.