Dependency injection using web services?

I recently discovered a possible candidate for dependency injection in a .NET application that I developed.

Due to recent organizational policies, it is no longer possible to call smtp mail services from client computers on our network. Therefore, I will have to reorganize all the code in my application, where previously it called the smtp object to send mail.

I created a new WCF web service on an authorized web server that allows you to send smtp mail messages.

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

My question is, is it possible, through dependency injection, to encapsulate the creation of the .NET WCF web service? I'm new to IoC and Dependency deployment infrastructures, so I'm not quite sure if it can work with web service dependencies?

I hope someone else there has encountered this situation or is aware of this subject?

amuses John

+3
source share
2 answers

Yes, it is possible to connect the WCF service with the constructor injector .

You can also use DI with WCF clients .

However, the script sounds strange. If you are not allowed to remotely connect to the SMTP server, why are you allowed to remotely connect to the same machine through SOAP?

+2

Ninject IoC WCF.

Grz, Kris.

0

Source: https://habr.com/ru/post/1750519/


All Articles