【发布时间】:2012-07-31 22:04:55
【问题描述】:
我正在使用 Castle WCF 集成工具,并且我的第一个 webHttp 端点一切正常。要使此端点正常工作,它要求端点启用了 WebHttpBehavior。我能够做到这一点:
container.Register(Component.For<IEndpointBehavior>()
.ImplementedBy<WebHttpBehavior>());
当我尝试使用与 WebHttpBehavior 不兼容的 BasicHttpBinding 启用第二个端点时,这会成为一个问题。
有没有办法指定上面的IEndPointBehavior注册只适用于某个端点?
这是我的完整服务安装程序:
container.AddFacility<WcfFacility>(f => f.CloseTimeout = TimeSpan.Zero)
.Register(Component.For<IDiagnosticService>()
.ImplementedBy<DiagnosticService>()
.Named("DiagnosticService")
.LifestyleTransient()
.AsWcfService(new DefaultServiceModel()
.Hosted()
.AddEndpoints(WcfEndpoint.BoundTo(new WebHttpBinding()).At("json"))
.AddEndpoints(WcfEndpoint.BoundTo(new BasicHttpBinding()).At("soap"))
.PublishMetadata(o => o.EnableHttpGet())));
container.Register(Component.For<IEndpointBehavior>()
.ImplementedBy<WebHttpBehavior>());
【问题讨论】:
-
WcfEndpoint 类接受 System.ServiceModel.ServiceEndpoint 的实例。使用它,我可以根据需要独立配置端点。这似乎工作正常,但我无法弄清楚如何处理相对寻址(即(local/ser.svc/json vs (local/ser.svc/soap) System.ServiceModel.EndpointAddress 的构造函数需要一个 URI。如果我把整个 uri (@987654323 @),我得到一个“没有协议绑定匹配”异常。如果我只使用 local/ser.svc 作为 URI,它可以工作,但我没有 /json 和 /soap 端点地址。
标签: wcf integration behavior castle endpoint