How Intercept HTTP calls from WCF client to service

Posted by Anuraj on Thursday, February 12, 2015

.Net .Net 4.0 ASP.Net Visual Studio WCF

Today I faced some problem, I had to intercept HTTP calls from WCF proxy to WCF service. I was using Fiddler 4. But unfortunely it was not working :( I tried many options.(It was not working for me, but it may work for you)

  1. By using system.net proxy setting - In the clientapp.exe.config, you need to add following configuration settings.
<system.net>
  <defaultProxy enabled="true">
    <proxy proxyaddress="http://127.0.0.1:8888" bypassonlocal="False" />
  </defaultProxy>
</system.net>
  1. By using useDefaultWebProxy attribute in the binding element.
<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding_IService1" 
             useDefaultWebProxy="false" />
  </basicHttpBinding>
</bindings>

For me it is also not working :(

  1. By using Hostname instead of localhost. - This is the only solution worked for me. :) Modify you clientapp.exe.config, and change the endpoint address from localhost to the actual host name.
<client>
  <endpoint address="http://anurajp/WcfService1/Service1.svc" 
      binding="basicHttpBinding"
      bindingConfiguration="BasicHttpBinding_IService1" 
      contract="ServiceReference1.IService1"
      name="BasicHttpBinding_IService1" />
</client>

This is the proxy request and response captured using Fiddler.

WCF Request and Response using Fiddler

Happy Programming :)



Did you like this article? Share it with your friends

Facebook Twitter Google+ LinkedIn Reddit StumbleUpon



MVP
Subscribe


Copyright © 2017 - Anuraj P. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Hosted with ❤ by GitHub