【发布时间】:2012-01-11 15:34:54
【问题描述】:
我有一个托管在 IIS 上的 ASP .Net MVC 3.0 Web 应用程序,我使用的是 Castle Windsor 3.0 版。
我想做的是使用 webHttpBinding 注册 WCF 服务,而 web.config 中没有任何条目或具有 .svc 文件。这可能吗?
我在我的 IWindsorInstaller 实现中尝试了这个:
container.AddFacility<WcfFacility>(f => f.CloseTimeout = TimeSpan.Zero);
container.Register(
Component
.For<IMyService>()
.ImplementedBy<MyService>()
.AsWcfService(new DefaultServiceModel()
.AddBaseAddresses("http://localhost/WebApp/Services")
.AddEndpoints(WcfEndpoint
.BoundTo(new WebHttpBinding())
.At("MyService.serv"))
.Hosted()
.PublishMetadata()));
我忽略了在全局 asax 的 RegisterRoutes 方法中完成 serv 的任何内容:
routes.IgnoreRoute("{resource}.serv/{*pathInfo}");
如果我将浏览器指向 http://localhost/WebApp/Services/MyService.serv,我会得到 404。
我做错了什么或者我想做一些愚蠢的事情(或不可能或两者兼而有之!)?
【问题讨论】:
-
只有当您使用特殊的
ServiceRoute为您的服务注册 URL 路由时才有可能,但我不知道它如何与 Castle Windsor 一起使用。 -
感谢 Ladislav,这给了我一个开始寻找的好地方!
标签: c# asp.net wcf castle-windsor