Castle WCF Container Configuration

I have real WCF Facility issues provided by Castle Windsor. I do not find relevant documentation that could give me some examples with the current version of WCF Facility.

The following is my scenario: I want to write a WCF service that will be displayed over TCP, which will be hosted by the Windows service.

I am unable to configure the WCF tool, where to configure it, whether it should be in the WCF service or on the Windows service host.

Also, how do I configure the WCF object when my service endpoints are declared in the WCF configuration file?

Can anybody help? The link would be greatly appreciated, although I could not find much.

0
source share
1 answer

This is an example / walk to set up a (contrived) service.

For my example, there is a service contract for WindsorWCF.IMyService and a service called WindsorWCF.MyService. I decided to configure the service with the TCP endpoint in the application configuration as follows:

<system.serviceModel> <services> <service name="WindsorWCF.MyService"> <endpoint name ="IMyService_Endpoint" address="net.tcp://localhost:9876/MyService" binding="netTcpBinding" contract="WindsorWCF.IMyService" /> </service> </services> </system.serviceModel> 

Then add the window configuration file (XML) to your service project and add the component to it:

 <configuration> <components> <component id="MyService" service="WindsorWCF.IMyService, WindsorWCF" type="WindsorWCF.MyService, WindsorWCF" /> </components> </configuration> 

In the service host application itself, I added the following code (I used the console application when I wrote the code, but the idea is the same):

 static void Main(string[] args) { InitWindsor(); var host = new DefaultServiceHostFactory().CreateServiceHost("MyService", new Uri[0]); host.Open(); Console.ReadLine(); } static IWindsorContainer Container { get; set; } private static void InitWindsor () { Container = new WindsorContainer().AddFacility<WcfFacility>().Install(Configuration.FromXmlFile("windsor.config")); } 

What is this for example - I hope this makes sense.

+2
source

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


All Articles