.NET Log Soap Request on Client

后端 未结 6 602
野趣味
野趣味 2021-01-05 09:49

I\'m consuming a third party .NET WebService in my client application. For debugging purposes I want to capture the SOAP requests that are being sent from my server. How w

相关标签:
6条回答
  • 2021-01-05 10:20

    I've used the Web Service, SOA and SOAP Testing Tool - soapUI with good success in the past.

    -Edoode

    0 讨论(0)
  • 2021-01-05 10:27

    Maybe wireshark ? I'm always using it for capturing traffic of my applications.

    0 讨论(0)
  • 2021-01-05 10:32

    I wrote a post about this a while ago titled "Logging SOAP Messages in .NET".

    The easiest way is to use the tools already provided with .NET.

    1. Extend the class SoapExtension.

    2. override the method ProcessMessage to get a full output of your Soap Request, then output this information to a text file or event log.

    public class SoapMessageLogger : SoapExtension
    {
      //…
      public override void ProcessMessage(SoapMessage message)
      {
        switch(message.Stage)
        {
          case SoapMessageStage.BeforeDeserialize:
            LogResponse(message);
            break;
          case SoapMessageStage.AfterSerialize:
            LogResponse(message);
            break;
          // Do nothing on other states
          case SoapMessageStage.AfterDeserialize:
          case SoapMessageStage.BeforeSerialize:
          default:
            break;
        }
      }
      //…
    }
    
    0 讨论(0)
  • 2021-01-05 10:37

    If it's for debugging purposes I'd just configure the web request to use a proxy and send the entire request though fiddler (http://www.fiddlertool.com) then you can see exactly what's getting transmitted over the wire.

    0 讨论(0)
  • 2021-01-05 10:43

    There are many options you can use. There are certainly some commercial tools for this (like SOAPScope), but if you're just looking to capture the raw contents of the requests/responses there are several tools out there besides Fiddler (that Walden mentioned already).

    Personally, I've been a long time user of Simon Fell's TcpTrace and YATT.

    If you're interested in actually instrumenting the code so that it can do it on its own (say, by logging everything to a file or something), then you might want to look into implementing a SoapExtension on your server.

    0 讨论(0)
  • 2021-01-05 10:45

    You can use a SoapExtension to log the Soap calls.

    http://msdn.microsoft.com/en-us/magazine/cc164007.aspx

    0 讨论(0)
提交回复
热议问题