-
Notifications
You must be signed in to change notification settings - Fork 198
How to capture SOAP messages
#Introduction When debugging Ads API calls, one important resource is the SOAP messages you send to the server. The following wiki shows how to obtain SOAP logs.
#Option 1: Use SOAP logs
The AdWords API client library logs SOAP requests through System.Trace. You can control the settings through your App.config / Web.config
using the following keys:
<system.diagnostics>
<sources>
<source name="AdsClientLibs.SoapXmlLogs"
switchName="AdsClientLibs.SoapXmlLogs"
switchType="System.Diagnostics.SourceSwitch">
<listeners>
<!-- Modify the initializeData attribute below to control the
path to the SOAP XML log file. -->
<add name="soapXmlLogListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="C:\Logs\soap_xml.log" />
<remove name="Default" />
</listeners>
</source>
<source name="AdsClientLibs.RequestInfoLogs"
switchName="AdsClientLibs.RequestInfoLogs"
switchType="System.Diagnostics.SourceSwitch">
<listeners>
<!-- Modify the initializeData attribute below to control the
path to the request info log file. -->
<add name="requestInfoLogListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="C:\Logs\request_info.log" />
<remove name="Default" />
</listeners>
</source>
</sources>
<switches>
<!-- Use this trace switch to control the SOAP XML logs written by Ads*
.NET libraries. The default level is set to Off. Logs are generated at
both the Error and Information levels. -->
<add name="AdsClientLibs.SoapXmlLogs" value="Off"/>
<!-- Use this trace switch to control the Request Info logs written by
Ads* .NET libraries. The default level is set to Off. Logs are
generated at both the Error and Information levels. -->
<add name="AdsClientLibs.RequestInfoLogs" value="Off"/>
</switches>
</system.diagnostics>
See this wiki article for more details.
#Option 2: Use Fiddler You can use Fiddler, an HTTP(S) proxy to capture traffic from the Ads API .NET client library. Fiddler is available for download from http://www.fiddler2.com/fiddler2/.
Once you download and start Fiddler, set your client library's proxy url using the following keys in App.config / Web.config
.
<add key="ProxyServer" value=""/>
<add key="ProxyUser" value=""/>
<add key="ProxyPassword" value=""/>
<add key="ProxyDomain" value=""/>
By default, Fiddler acts as a proxy on localhost:8888, so you can set your ProxyServer
key to http://localhost:8888. You also need to turn on HTTPS decryption. Various fiddler options are explained on http://www.fiddler2.com/Fiddler/help/OptionsUI.asp.
#Option 3: Use System.Net tracing
Options 1 and 2 are good for most situations, but if you absolutely need the raw logs for the HTTP(S) calls you make, then you can use System.Net tracing options. You need to add the following lines to your App.config
to achieve this:
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.Net">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.Sockets">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.Cache">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add
name="System.Net"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="System.Net.trace.log"/>
</sharedListeners>
<switches>
<add name="System.Net" value="Verbose" />
<add name="System.Net.Sockets" value="Verbose" />
<add name="System.Net.Cache" value="Verbose" />
</switches>
</system.diagnostics>
When you run your application, the detailed trace will be written to System.Net.trace.log
.