locked
How to know function name being called in Web Service registered with HttpModule RRS feed

  • Question

  • User-530506546 posted

    Hello,

    How i can know the function name that is being called in Web Service ,  in the HttpModule.

    Also i have created a web service and created an HttpModule . Registered Web Service with HttpModule.

    How i can get the function name that is being called by user in HttpModule.

    I have put code in Init method of Httpmodule and also registered with begin request event as below:

     

    public class MyClass:IHttpModule
        {
            public void Init(HttpApplication context)
            {
                context.BeginRequest+=new EventHandler(context_BeginRequest);
            }

            public void context_BeginRequest(Object s, EventArgs e)
            {
     
             }

         |
       

    Thanks

     

    Wednesday, October 26, 2011 6:52 AM

All replies

  • User-2016190530 posted

    Hi,

    What you  are trying to achive can only be done using AOP (Aspect oriented programming).  It cannot be done using httpmodules.

    Its a classic cross cut concern, which involves method interecption. 

    C# and .net do not support this out of the box, but there are many 3rd party frameworks out there which allow you to achive this.

    .net has been designed to support this feature in the future. It can easily be achived by using attributes on classes and methods.

    But when and if they will ever get around to including it in the framework is not sure.

    For now you are better of using a established 3rd party library. Some require a licence some are free. 

    Here are some links.

    http://www.developerfusion.com/article/5307/aspect-oriented-programming-using-net/3/

    http://www.sharpcrafters.com/

    Wednesday, October 26, 2011 11:59 AM
  • User-530506546 posted

    Hello,

    Thanks for your reply. Actually i want to Log Errors in the Web Service using HttpModules which is quite possible. So i also wanted to log in which function the error has occured. So i wanted to know function name..

    thanks.

    Thursday, October 27, 2011 5:21 AM
  • User-2016190530 posted

    Oh my bad then, in that case things work out much easier. 

    What your are requesting to do is known as ELMAH's Architecture.

    There are some well know ways to implement this. 

    Here's MSDN write up on it. http://msdn.microsoft.com/en-us/library/aa479332.aspx

    Thursday, October 27, 2011 7:07 AM
  • User-530506546 posted

    Hello,

    There is a note given in above link :

    Note   For more information on creating custom error pages, read Eli Robillard's article Rich Custom Error Handling with ASP.NET.
    Note   When an unhandled exception occurs in an ASP.NET Web service, the
    Error
    event is not bubbled up to HTTP modules and thus ELMAH. Rather, it is intercepted by the ASP.NET runtime and a SOAP fault is returned to the client. To have an error logged in a Web service, you would need to create a SOAP Extension that listened for SOAP faults.
     
     
    It can not be done using ELMAH rather not that much simple and easy -:). and is possible using SOAP Extension, can somebody please provide me simple example code. I find it hard that's provided in above link of SOAP Extension.
     
    Thanks
    Thursday, October 27, 2011 2:30 PM