2013-02-01 33 views
0

我们使用WCFFacility从托管(IIS 7.5)环境设置服务。 我们需要的是为每个服务提供两个端点,为.NET客户端提供WSHttp,为其他人提供WebHttp。这可能吗?使用WCFFacility为托管服务提供WS/Rest端点

的代码,我们使用:

_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") 
     )) 
    ); 

然后:

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

我认为我们真的不能混用WS /网络端点,但可以这样莫名其妙其他实现?我们不想回退到xml配置,但我们需要配置端点。

+0

根据我的经验,你真的无法写出符合SOAP和REST期望的一个实现。 –

+0

@rarouš,为什么不呢? afaik,属性或其他配置没有冲突,我需要的是指定不同的端点。我有点解决它,如果你好奇,看看我的答案。 – Kostassoid

+0

Becaure REST关于操作的资源和SOAP。他们是不同的范例。至少他们在API级别上具有非常不同的错误处理... –

回答

1

经过整整一天的挖掘和尝试,我找到了解决方案。除了最终获得帮助/ wsdl页面之外,没有以任何方式进行测试。所以我把问题留待一段时间。

_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))); 
相关问题