2

I'm using this method to achieve DI in WCF. Now I'm at the point where I need to configure the endpoints and bindings.

How and where should I do this?

Community
  • 1
  • 1
makerofthings7
  • 60,103
  • 53
  • 215
  • 448
  • It all depends on the DI container you are using... some are easy like Windsor which has a Wcf Facility. – CrazyDart Mar 18 '11 at 22:33
  • 1
    In what way do you think using an Instance provider conflicts with the usual ways of providing your endpoint setup? – flq Mar 18 '11 at 22:35
  • I looked at the SO link you provided and I dont agree with the answer you selected... why chisel your own wheel out of stone when you could have just used the Wcf Facility??? The very next answer was to use the Wcf Facility... which I have used many times and it works great. – CrazyDart Mar 18 '11 at 22:44
  • 1
    @CrazyDart - I am looking at that solution with Unity because I want to stick with Microsoft technologies. Windsor / Castle doesn't seem to be a MSFT technology. Unity however is. – makerofthings7 Mar 19 '11 at 06:06
  • Got it. It does help knowing what DI you are using. What @flq and and @Mark-Seemann are saying is that you configure using the same way you would without a DI setup... not sure I totally agree, but for the most part thats correct. This will depend on the WCF template you used. Have you looked for some blog posts on this yet? I found a few using Google... I know thats not a MS product, but it seems to be reliable. ;-) – CrazyDart Mar 21 '11 at 19:05
  • @CrazyDart I had nothing in my System.ServiceModel and the DI by @Mark Seemann just worked. I was happy and suprised that everything worked just as usual, just with the special DI wrapper. Thanks everyone – makerofthings7 Mar 21 '11 at 19:51

2 Answers2

1

The comment by flq is provides the answer: you can still use the normal WCF configuration settings even if you use an IInstanceProvider.

Since this is the idiomatic way of configuring WCF I see no reason to do it in any other way. It provides flexibility, there's tool support, and you'd be using the documented API.

Mark Seemann
  • 225,310
  • 48
  • 427
  • 736
  • I'm new to using WCF Factories, and that is throwing me off on an exact web.config example. I'll make a sample as soon as I understand WCF enough, or have courage/patience to do a trial-by-error approach. – makerofthings7 Mar 19 '11 at 23:54
0

For windsor on the REST 4 template this is how I register the routes...

// SOAP Endpoint
RouteTable.Routes.Add(new ServiceRoute("myendpointname/soap",
    new WindsorServiceHostFactory<Castle.Facilities.WcfIntegration.DefaultServiceModel>(), typeof(IMyEndPointService)));

// REST Endpoint
RouteTable.Routes.Add(new ServiceRoute("myendpointname",
    new WindsorServiceHostFactory<RestServiceModel>(), typeof(IMyEndPointService)));
CrazyDart
  • 3,803
  • 2
  • 23
  • 29