2

I have a program that sends data to a web service and stores the data into an XML file. I would like to know if there's a class or a method that can catch the soap object that traveling to the service and dump it to a text file. Can anyone tell me how to do this?

edit 1:

ok so after going through the topic posted in the comment i edited my web.config file to look like this:

<?xml version="1.0"?>
<configuration>

<configSections>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
        <section name="XML_New.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
</configSections>
<appSettings>
<add key="username" value="admin"/>
<add key="password" value="admin"/>
</appSettings>
<connectionStrings/>
<system.diagnostics>
<sources>
  <source name="System.ServiceModel.MessageLogging">
    <listeners>
      <add name="messages"
      type="System.Diagnostics.XmlWriterTraceListener"
      initializeData="c:\logs\messages.svclog" />
    </listeners>
  </source>
</sources>
</system.diagnostics>

<system.serviceModel>
<diagnostics>
  <messageLogging logEntireMessage="true"
logMalformedMessages="true"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true"
maxMessagesToLog="420">
    <filters>
      <add nodeQuota="10" 
   xmlns:soap="http://www.w3.org/2003/05/soap-envelope">

/soap:Envelope/soap:Header
      </add>
    </filters>
  </messageLogging>
</diagnostics>
</system.serviceModel>
<system.web>
    <compilation debug="true" >

    </compilation>
<authentication mode="Forms" />
</system.web>
<applicationSettings>
    <XML_New.Properties.Settings>
        <setting name="XML_New_localhost_Service1" serializeAs="String">
            <value>http://localhost:1689/Admin.asmx</value>
        </setting>
    </XML_New.Properties.Settings>
</applicationSettings>
</configuration>

the file should be logged to c:\logs\messages.svclog but for soeme reason it doesnt. anyone have an idea why?

Denis Kralj
  • 633
  • 2
  • 12
  • 27
  • nothing yet, i don't know if there is a method apart from watching the traffic via wireshark. – Denis Kralj Feb 02 '12 at 22:12
  • possible duplicate of [C# SOAP Web Services client - example that shows how to log all raw SOAP intput and output?](http://stackoverflow.com/questions/566855/c-sharp-soap-web-services-client-example-that-shows-how-to-log-all-raw-soap-in) – MK. Feb 02 '12 at 22:14
  • @MK thanks ill look int this and ill post aditional question is i have then. – Denis Kralj Feb 02 '12 at 22:30
  • Sort of dup of http://stackoverflow.com/questions/2587952/is-there-a-way-to-get-the-raw-soap-request-from-within-a-asp-net-webmethod – ryber Feb 02 '12 at 23:23

2 Answers2

4

At the asmx service level, you can use soap extensions. Docs and working example here: http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soapextension.aspx. You can probably copy-paste that whole thing, change the dump path in GetInitializer, and it might just work for you. +1

  • Actually, this apparently can be plugged in at the client also (.net/soap based). I didn't know that myself. I did this at asmx multiple times; works like a charm. –  Feb 03 '12 at 14:33
0

You can use FiddlerCore to intercept SOAP on HTTP and save all the data you want from the requests and responses.

http://www.fiddler2.com/fiddler/Core/

Bjørn Otto Vasbotten
  • 1,673
  • 1
  • 23
  • 32