Soap at .net

I have an internal corporate application that currently consumes 10 different web services. They are used in the old Web Links style instead of using WCF.

The problem I am facing is trying to work with other teams in the company that create the services that I consume. I found that I need to record the exact SOAP messages that I send and receive. I did this by creating a new attribute that extends SoapExtensionAttribute. Then I just add this attribute to the service method in the generated Reference.cs file. It works, but painfully for two reasons. Firstly, this is a generated file, so everything I do there can be overwritten. Secondly, I should forget to remove the attribute before checking in the file.

Is there a better way to capture the exact SOAP messages that I send and receive?

+4
source share
5 answers

This seems to be a general question since I just asked him and they told me to look here .

You do not need to edit the generated Reference.cs . You can reference the extension in your app.config application.

+4
source

Is this a webapp?

Put the SoapExtension code in the HTTPModule and paste the SOAP envelope into the HTTPOutput stream.

Thus, when in debug mode, I draw something like a collapsible div at the top of the page, which lists all the SOAP messages for this page.

+3
source

I have already created an HTTPModule that does this, I will strip information about my company and publish goodies later today.

Also check out SoapUI, its handy tool.

+2
source

You can do this by creating SoapExtention. Check out this article .

+1
source

I used the following code - an example of how I captured SOAP requests in an application written some time ago.

 <System.Diagnostics.Conditional("DEBUG")> _ Private Sub CheckHTTPRequest(ByVal functionName As String) Dim e As New UTF8Encoding() Dim bytes As Long = Me.Context.Request.InputStream.Length Dim stream(bytes) As Byte Me.Context.Request.InputStream.Seek(0, IO.SeekOrigin.Begin) Me.Context.Request.InputStream.Read(stream, 0, CInt(bytes)) Dim thishttpRequest As String = e.GetString(stream) My.Computer.FileSystem.WriteAllText("D:\SoapRequests\" & functionName & ".xml", thishttpRequest, False) End Sub 

Setting a conditional attribute, like me, makes the compiler ignore the method call for all types of assemblies except debugging.

Sorry for VB, this is imposing on me.

0
source

Source: https://habr.com/ru/post/1276628/


All Articles