capture of .net framework console app issuing soap client proxy and WebClient calls

641 views
Skip to first unread message

robertob

unread,
Mar 21, 2013, 4:53:54 PM3/21/13
to httpf...@googlegroups.com
i'm trying to capture generated by a .net framework 4.0 console app that issues both soap client proxy, i.e. add service reference, and WebClient rest calls.
 
presumably neither of these emit their http calls using wininet api and therefore desktop browser proxy settings that fiddler creates have no effect.
 
I thought I recall something about setting system level http proxy settings using commands such as the following but that doesn't seem to work either.
 
    netsh winhttp set proxy proxy-server="127.0.0.1:8888" bypass-list="<-loopback>" & netsh winhttp show proxy
 
Any pointers?
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

robertob

unread,
Mar 22, 2013, 10:20:59 AM3/22/13
to httpf...@googlegroups.com
I reviewed forum search hit reference to http://www.fiddler2.com/fiddler/help/hookup.asp#q-dotnet for details on this subject.  
 
What I found after some testing was that the App.config defaultProxy settings it outlined allowed me to enable fiddler capture of just my app's traffic without having to have fiddler f12 global wininet capture enabled.  This was helpful if you want an easy way to isolate capture to just traffic from soap and rest client app debug/test work you are doing.
 
I also found that I needed to set hostname in soap and rest client service call, when service i'm calling is locally hosted, to netbios or ipv4 address in order in order for fiddler capture to work regardless of whether I enabled fiddler capture using f12 global wininet settings or app only App.config defaultProxy settings.
 
<configuration>
  <system.net>
    <defaultProxy>
      <!-- see http://msdn.microsoft.com/en-us/library/kd3cf2ex.aspx and http://www.fiddler2.com/fiddler/help/hookup.asp#q-dotnet -->
      <!--<proxy autoDetect="False" bypassonlocal="True" proxyaddress="http://itgproxy:80" usesystemdefaults="True" />
      <bypasslist><add address="[a-z]+\.mysandbox\.com" /></bypasslist>-->
      <proxy autoDetect="False" bypassonlocal="False" proxyaddress="http://127.0.0.1:8888" usesystemdefault="False" />
      <bypasslist><add address="&lt;-loopback&gt;"/></bypasslist>
      <!--<proxy autoDetect="True" bypassonlocal="False" usesystemdefault="True" />-->            
    </defaultProxy>
  </system.net>
 
//var hostname = "localhost";  // if not running fiddler capture use value that is supported by ssl cert settings
var hostname = Environment.MachineName;  // if running defaultProxy enabled fiddler capture use netbios or ipV4 address
 
IService1 soapClient = new Service1Client("soap", "https://" + hostname + "/WcfService1/Service1.svc");
var soapResult1 = soapClient.GetData(42);
var soapResult2 = soapClient.GetDataUsingDataContract(new ServiceReference1.CompositeType() { BoolValue = true, StringValue = "hello world" });
 
WebClient restClient = new WebClient();
restClient.UseDefaultCredentials = true; 
var restResult0 = restClient.DownloadString("https://" + hostname + "/WcfService1/Service1.svc/rest/help");  // wcf rest $metadata story
var restResult1 = restClient.DownloadString("https://" + hostname + "/WcfService1/Service1.svc/rest/GetData?value=42");
restClient.Headers[HttpRequestHeader.ContentType] = "application/json; charset=utf-8";
var restResult2 = restClient.UploadString("https://" + hostname + "/WcfService1/Service1.svc/rest/GetData/UsingDataContract", "{\"BoolValue\":true, \"StringValue\":\"hello world\"}");
 

EricLaw

unread,
Mar 22, 2013, 10:58:06 AM3/22/13
to httpf...@googlegroups.com
That's correct; as noted here: http://www.fiddler2.com/fiddler/help/hookup.asp#Q-LocalTraffic, the .NET Framework is hardcoded to bypass the proxy for "localhost"; unlike WinINET, they have not (yet) supported the <-loopback> token. 
Reply all
Reply to author
Forward
0 new messages