Kostassoid
Kostassoid

Reputation: 1898

Providing both WS/Rest endpoints for hosted services using WCFFacility

We are using WCFFacility to setup services from hosted (IIS 7.5) environment. What we need is to provide two endpoints for each service, WSHttp for .NET clients and WebHttp for everyone else. Is this possible?

The code we use:

_container.Register(
    Component
        .For<ISomeService>()
        .ImplementedBy<SomeService>()
        .AsWcfService(new DefaultServiceModel()
        .Hosted()
        .PublishMetadata(mex => mex.EnableHttpGet())
        .AddEndpoints(
            WcfEndpoint.BoundTo(new WSHttpBinding()).At("v1/ws"),
            WcfEndpoint.BoundTo(new WebHttpBinding()).At("v1/rest")
        ))
    );

And then:

RouteTable.Routes.Add(new ServiceRoute("", new DefaultServiceHostFactory(_container.Kernel), typeof(ISomeService)));

I assume we can't really mix ws/web endpoints but can this be achieved somehow else? We don't want to fallback to xml configuration but we need to configure endpoints.

Upvotes: 0

Views: 327

Answers (1)

Kostassoid
Kostassoid

Reputation: 1898

After the whole day of digging and trying I've found the solution it seems. Not tested in any way apart from finally getting help/wsdl pages. So I leave the question open for a while.

_container.Register(
    Component
    .For<ISomeService>()
    .ImplementedBy<SomeService>()
    .AsWcfService(new RestServiceModel().Hosted())
    .AsWcfService(new DefaultServiceModel().Hosted()
        .PublishMetadata(mex => mex.EnableHttpGet())
        .AddEndpoints(
            WcfEndpoint.ForContract<ISomeService>().BoundTo(new WSHttpBinding())
        )
    )
);

RouteTable.Routes.Add(new ServiceRoute("v1/rest", new WindsorServiceHostFactory<RestServiceModel>(_container.Kernel), typeof(ISomeService)));
RouteTable.Routes.Add(new ServiceRoute("v1/ws", new WindsorServiceHostFactory<DefaultServiceModel>(_container.Kernel), typeof(ISomeService)));

Upvotes: 1

Related Questions