How to use unity in web service

Jan 28, 2009 at 9:07 PM
I have a web service like this

    public class WebLoggingService : WebService
    {
        ILog logger;

        [Dependency]
        public ILog Logger
        {
            set { logger = value; }
        }

        [WebMethod]
        public void Log(string message)
        {
            logger.Write(message);
        }
    }

Is there a place(using http module) in the http request pipeline to do the injection of ILog using Unity?

Thanks,

Chester


Jan 30, 2009 at 6:48 AM
Hi,

Please see this thread: http://www.codeplex.com/unity/Thread/View.aspx?ThreadId=36990

also this link: http://blogs.msdn.com/mpuleio/archive/2008/07/17/proof-of-concept-a-simple-di-solution-for-asp-net-webforms.aspx


Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com
Jan 30, 2009 at 3:08 PM
Edited Jan 30, 2009 at 3:25 PM
Thank you for your reply.

But my question is how to inject into a WEB SERVICE in http module. For aspx page there are bunch of solutions out there.

And also the web service isn't supposed to be wrapped in a WCF service.

Thanks,

Chester
Jan 30, 2009 at 5:12 PM
Michael Puleio (a fellow p&p dev) and I went looking for exactly this hook a couple of months ago. Unfortunately, we didn't find one - as far as I know there's no way to hook the construction of ASMX web service objects.

We did come up with a workaround, though. Check out Mike's blog here to see what we ended up with. The web service stuff is at the end of the post.

Jan 30, 2009 at 5:22 PM
Thanks, got it.

Chester