get SOAP envelope XML
LuisLeguizamon opened this issue · 2 comments
Hi.
How can I catch/get the entire SOAP envelope XML that is sent? Mi goal is to get the entire message that have been sent and save it.
Actually I am saving the XML body (the one that I pass to PostAsync function) but I need the entire message on SOAP.
Yes, you can do this as it is shown on a test :)
- Create a class the inherits from
HttpMessageHandler
: https://github.com/pmorelli92/SoapHttpClient/blob/main/Tests/SoapHttpClient.Tests/TestMessageHandler.cs#L23 - Create an
IHTTPClientFactory
that uses the previously defined handler: https://github.com/pmorelli92/SoapHttpClient/blob/main/Tests/SoapHttpClient.Tests/TestMessageHandler.cs#L8 - Create the
SoapHttpClient
instance using that factory: https://github.com/pmorelli92/SoapHttpClient/blob/main/Tests/SoapHttpClient.Tests/SoapClientTests.cs#L77-L78 - Access to the handler to fetch the soap envelope: https://github.com/pmorelli92/SoapHttpClient/blob/main/Tests/SoapHttpClient.Tests/SoapClientTests.cs#L84
https://github.com/pmorelli92/SoapHttpClient/blob/main/Tests/SoapHttpClient.Tests/SoapClientTests.cs#L109
Thank you so much for the answer.
I've tried what you suggested and I get the entire SOAP request, but I am not understanding something. Inside the override function "SendAsync" https://github.com/pmorelli92/SoapHttpClient/blob/main/Tests/SoapHttpClient.Tests/TestMessageHandler.cs#L40
How can I return the response or how can I return the base Send Async function? ( base.SendAsync(request, cancellationToken) )
I have searched but the examples that I found used a "DelegatingHandler"