首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用WCFFacility为托管服务提供WS/Rest端点

使用WCFFacility为托管服务提供WS/Rest端点
EN

Stack Overflow用户
提问于 2013-02-01 18:32:47
回答 1查看 322关注 0票数 0

我们正在使用WCFFacility从托管(IIS7.5)环境中设置服务。我们需要为每个服务提供两个端点,用于.NET客户端的WSHttp和用于其他所有客户端的WebHttp。这个是可能的吗?

我们使用的代码:

代码语言:javascript
复制
_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")
        ))
    );

然后:

代码语言:javascript
复制
RouteTable.Routes.Add(new ServiceRoute("", new DefaultServiceHostFactory(_container.Kernel), typeof(ISomeService)));

我假设我们不能真的混合ws/web端点,但这能以其他方式实现吗?我们不想退回到xml配置,但我们需要配置端点。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-02-04 18:03:53

经过一整天的挖掘和尝试,我似乎找到了解决方案。除了最终获得帮助/wsdl页面之外,没有以任何方式进行测试。因此,我暂时不考虑这个问题。

代码语言:javascript
复制
_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)));
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14644342

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档