0

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.

Kostassoid
  • 1,870
  • 2
  • 20
  • 29
  • From my experience you cant really write one implementation that conforms both SOAP and REST expectations. – Aleš Roubíček Feb 02 '13 at 10:55
  • @rarouš, why not? afaik, there're no conflicts in attributes or any other configuration, all i need is to specify the different endpoints. i sort of solved it, see my answer if you're curious. – Kostassoid Feb 04 '13 at 10:06
  • Becaure REST is about resources and SOAP about actions. They are different paradigms. At least they have very different error handling on API level... – Aleš Roubíček Feb 05 '13 at 08:08
  • @rarouš, good points! but REST is still about actions, i can combine both paradigms by providing RPC-style method names with REST-style call pattern. as for the error-handling, i managed to return correct fault message from REST endpoint, i could also intercept the response and by analyzing it provide correct status codes. workarounds and hacks, true, but manageable. – Kostassoid Feb 05 '13 at 10:03

1 Answers1

1

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)));
Kostassoid
  • 1,870
  • 2
  • 20
  • 29