2
我正在使用Castle WCF集成工具,并且我已经为我的第一个webHttp端点正常工作。要使此端点起作用,它需要端点启用WebHttpBehavior。我能做到这一点使用:指定城堡WCF集成工具每个端点的端点行为
container.Register(Component.For<IEndpointBehavior>()
.ImplementedBy<WebHttpBehavior>());
这将成为一个问题,当我尝试启用使用basicHttpBinding的第二端点这是不符合的WebHttpBehavior兼容。
有没有办法指定上面的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的一个实例。使用这个我可以根据需要独立配置端点。这似乎工作正常,但我无法弄清楚如何处理相对寻址(即(http://local/ser.svc/json vs(http://local/ser.svc/soap) )的构造函数System.ServiceModel.EndpointAddress需要一个URI,如果我把整个uri(http://local/ser.svc/json“),我得到一个”无协议绑定匹配“异常如果我只使用http:// local /ser.svc作为URI,它可以工作,但我没有/ json和/ soap端点地址。 – Bluffrock 2012-07-31 23:39:09