Reputation: 633
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?
Upvotes: 2
Views: 3287
Reputation: 1701
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/
Upvotes: 0
Reputation:
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
Upvotes: 4