Pergunta

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.

Foi útil?

Solução

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)));
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top