在Castle WCF Facility中托管Web Http绑定服务

时间:2013-07-23 10:44:58

标签: c# wcf castle-windsor

我有一个WCF服务,我希望在Castle WCF工具中托管多个绑定,其中一个是WebHttp。我已经完成了Specifying Castle WCF Integration Facility Endpoint Behavior per Endpoint所述的相同配置。 如果我用WebHttpBehavior注册IEndpointBehavior,因为任何人都可以猜测WebHttp以外的绑定失败。所以我没有注册。这样只有TCP绑定才有效。 对于WebHttp绑定,我做错了什么?这是我的代码。

string internalEndpointAddress = "http://localhost:8899/DummyService";

ContractDescription description = ContractDescription.GetContract(typeof(IDummyService));

// Create webHTTP Binding            
WebHttpBinding webhttpbinding = new WebHttpBinding();

EndpointAddress webEndpointAddress = new EndpointAddress(internalEndpointAddress);
    ServiceEndpoint webEndpoint = new ServiceEndpoint(description, webhttpbinding, webEndpointAddress);
    webEndpoint.Behaviors.Add(new WebHttpBehavior());

//And here is the wcf registration. To keep it clean I removed net tcp registration...

container.AddFacility<WcfFacility>(f => f.CloseTimeout = TimeSpan.Zero)
                     .Register(Component.For<IDummyService>()
                        .ImplementedBy<DummyService>()
                        .LifestyleTransient()
                        .AsWcfService(new DefaultServiceModel()
                                        .Hosted()
                                        .AddEndpoints(WcfEndpoint.FromEndpoint(webEndpoint))
                                        .PublishMetadata(o => o.EnableHttpGet())));

0 个答案:

没有答案