Dependency injection with web services?

Posted by John K. on Stack Overflow See other posts from Stack Overflow or by John K.
Published on 2010-06-17T15:17:08Z Indexed on 2010/06/17 15:23 UTC
Read the original article Hit count: 328

I've recently discovered a possible candidate for dependency injection in a .Net application I've designed.

Due to a recent organizational policy, it is no longer possible to call smtp mail services from client machines on our network. So I'm going to have to refactor all the code in my application where it was previously calling the smtp object to send out mail.

I created a new WCF web service on an authorized web server that does allow for smtp mail messaging.

This seems to be a great candidate for dependency injection. I will create a new INotification interface that will have a method like 'void SendNotification(MailMessage msg)' and create a new property in my application where you can set this property to any class that implements this interface.

My question tho, is whether it's possible, through dependency injection, to encapsulate the instantiation of a .NET WCF web service? I am fairly new at IoC and Dependency injection frameworks, so I am not quite sure if it can handle web service dependencies?

I'm hoping someone else out there has come across this situation or has knowledge regarding this subject?

cheers, John

© Stack Overflow or respective owner

Related posts about .NET

Related posts about web