Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need svc file to setup Castle Wcf Facility for non-HTTP services

I am confused about the castle wcf facility registration.

I read some blog posts for BasicHttpBinding. But could not find a clear easy sample to setup a net.tcp setup.

I want to host the service from a console application...

I wrote something like this... can you see a problem here?

_container = new WindsorContainer();
_container.AddFacility<WcfFacility>();

_container.Register(Component.For<IMembershipService>().ImplementedBy<MembershipService>()
    .AsWcfService(
        new DefaultServiceModel()
            .AddEndpoints(WcfEndpoint
                    .BoundTo(new NetTcpBinding() { PortSharingEnabled = false })
                    .At("net.tcp://localhost/MembershipService")
            )
            .PublishMetadata()
    )
);
like image 303
Serdar Avatar asked Nov 03 '11 21:11

Serdar


1 Answers

If you wish to publish metadata you will need to enable port sharing (to let the MEX endpoint share the same port as the regular TCP port - you'll get an AddressAlreadyInUse exception if you have this set to false) and you probably need to specify a port on your URL (not sure what port TCP would use otherwise), so your code should be (assuming port 8080 is OK for you):

_container.Register(Component.For<IMembershipService>().ImplementedBy<MembershipService>()
    .AsWcfService(
        new DefaultServiceModel()
            .AddEndpoints(WcfEndpoint
                    .BoundTo(new NetTcpBinding() { PortSharingEnabled = true})
                    .At("net.tcp://localhost:8080/MembershipService")
            )
            .PublishMetadata()
    )
);

This works fine using castle windsor 3.0.

like image 144
kmp Avatar answered Sep 22 '22 21:09

kmp