Showing posts with label trace. Show all posts
Showing posts with label trace. Show all posts

Monday, March 26, 2012

Intercept Exceptions

I was wanting to trap Exceptions that occur in a Web Service, adjust the message (make sure stack trace does not get sent (I know about CustomErrors in web.config)) and put the message in a log.

I found out about SoapExtensions and created such, but just was not able to reach any breakpoints. I then read that I wouldn't reach it unless through a Soap request. So I used WebServiceStudio.exe and hit those breakpoints.

Well, when using Atlas, the full exception was being sent without running through the SoapExtension. I assume now that xmlhttp uses Post requests. Then in web.config WebServices node, I cleared the protocols and added only the Soap protocols... interesting thing is Atlas still called the web service and got the thrown error returned. That made me think it used Soap, but it still never hit the SoapExtension.

Could somebody clear up this confusion? I assume there must be a way to globally intercept Web Service errors. For Web Applications, I use global.asax Application_Error.

Nathan

Atlas does not use SOAP. It uses REST and the serialization method is JSON. Atlas has a custom HTTP Handler for .asmx files, which you can see in your wen.config file. When an Atlas script requests a web service, a special query string parameter named "mn" is appended to the url. The server side web service checks the presense of this parameter and and if it is present it uses custom processing bu Atlas otherwise it uses the default web service handler.The normal processing, which you expect when you call a web service like soap extension execution etc. no longer happens because of the Atlas custom handler. The Atlas custom handler directly catches the excpetion from the web service method and reports to the client, when the web service is invoked from an Atlas script. There is only one option currently (may change in future) and that is to handle the exceptions in the web service methods themshelves. I do not think that there is any global exception hooking mechanism you can use for Atlas.

Wednesday, March 21, 2012

Is is possible to trace and/or log HTTP requests made by ATLAS components?

I'd like to be able to trace any HTTP requests made to the server via ATLAS components. My understanding is that everytime the ATLAS framework uses the XmlHttpRequest object an HTTP operation (GET/POST) is issued to the server, I'd like to be able to log those requests and somehow I'm not able to see them via the trace.axd or IIS log.Not sure why you can't see them in the IIS log (are they being filtered out?), but you could see whats happening in the browser via a HTTP tracing tool. I have one as part of my Web Development Helper (athttp://www.nikhilk.net/Project.WebDevHelper.aspx) Hope that helps...
Thanks Nikhil for your reply. I noticed that all of the samples I was trying were posting to web services, for which I was seeing the corresponding requests in the logs. I installed the Web Development Helper and it is very helpful, I was looking for a tool like that, thanks for the tip!

There is a really valuable tool available for watching HTTP traffic in real time.

http://www.fiddlertool.com/fiddler/

This tool will let you watch all incoming/outgoing traffic and you can put breakpoints on the traffic and "fiddle" with it. Hope it can be of use to you!