Soap and Fiddler

Soap and Fiddler

by blamoreaux 15. August 2007 09:06

A coworker told me about a strange error he was getting when trying to call a webservice with an ASP 2.0 application. My first thought was, use Fiddler and inspect the soap call directly.

Setting up an application to point to Fiddler is a little different between .NET 1.1 and .NET 2.0. In 1.1 apps you'll need to configure the app.config or web.config to use Fiddler as a proxy. Add the following to the config file. 


<?xml version="1.0" encoding="utf-8"?>

<configuration>

  <system.net>

   <defaultProxy>

      <proxy proxyaddress="http://localhost:8888" bypassonlocal="false"/>

   </defaultProxy>

  </system.net>

</configuration>


Apparently for .NET 2.0 this isn’t needed anymore. My guess is somehow application in 2.0 use the WinINET API. If an application implements this API then when Fiddler has the “Act as System Proxy” checked, all http traffic will use fiddler as the proxy. Pretty neat!

So now fiddler is capturing all of the http traffic for our app and that includes the SOAP calls to the webservice. The error, “Underlying connection was closed”, is being thrown after one call to the web service is made and a seccond call is attempted. Doing some digging found Fiddler has a rule built in just for this error. Go to Fiddler and un-comment the connection closure rule in Rules -> Customize Rules ->| OnBeforeResponse.

    1 static function OnBeforeResponse(oSession:Fiddler.Session)

    2 {

    3    if (m_Hide200s && oSession.responseCode == 200){

    4       oSession["ui-hide"] = "true";

    5    }

    6 

    7    // Uncomment to reduce incidence of "unexpected socket closure" exceptions in .NET code. 

    8    // Note that you really should also fix your .NET code to gracefully handle connection closes.

    9    //

   10    // if ((oSession.responseCode != 401) && (oSession.responseCode != 407){

   11    //   oSession.oResponse["Connection"] = "close";

   12    // }

   13 

   14 }

I don't really know what is meant by "you should fix your code to gracefully handle connection closes" in our case of calling a web service. Right now the guess is the wsdl file being used isn't correct.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag




Live preview

January 5. 2009 22:40

Gravatar

Powered by BlogEngine.NET 1.1.0.7
Theme by Mads Kristensen

Subscribe

About the author

Brig Lamoraeux Brig Lamoreaux
I'm a .Net developer.

E-mail me Send mail

Calendar

<<  January 2009  >>
MoTuWeThFrSaSu
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar

Pages

Recent posts

Recent comments

Tags

Categories


Archive

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2006-2009

Sign in