指定每个端点的Castle WCF集成设施端点行为 [英] Specifying Castle WCF Integration Facility Endpoint Behavior per Endpoint

查看:110
本文介绍了指定每个端点的Castle WCF集成设施端点行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Castle WCF集成工具,并且我的第一个webHttp端点一切正常.为了使该端点正常工作,它要求该端点启用了WebHttpBehavior.我能够使用以下方法实现这一点:

I'm using Castle WCF Integration Facility and I have everything working properly for my first webHttp endpoint. For this endpoint to work, it requires that the endpoint have the WebHttpBehavior enabled. I was able to achieve this using:

           container.Register(Component.For<IEndpointBehavior>()
                            .ImplementedBy<WebHttpBehavior>());

当我尝试使用与WebHttpBehavior不兼容的BasicHttpBinding启用第二个端点时,这成为一个问题.

This becomes a problem when I try to enable a second endpoint using BasicHttpBinding which is not compatible with the WebHttpBehavior.

是否可以指定上面的IEndPointBehavior注册仅适用于某个终结点?

Is there someway to specify that the IEndPointBehavior registration above is only applicable to a certain endpoint?

这是我的完整安装程序:

This is my full installer for the service:

           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>());

推荐答案

好.我终于想通了.事实证明,我的大部分问题与Azure仿真环境有关,而不是与Castle WCF集成有关.答案很简单-只需设置ServiceEndpoint实例并使用WcfEndpoint.FromEndpoint()方法即可.

Ok. I finally figured this out. Turns out that the majority of my problem had to do with the Azure emulation environment rather than Castle WCF Integration. The answer is pretty straight forward -- just setup the ServiceEndpoint instances and use the WcfEndpoint.FromEndpoint() method.

这是我正在工作的安装程序:

Here is my working installer:

        String internalEndpointAddress = string.Format("http://{0}/DiagnosticService.svc", 
                                           RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Endpoint1"].IPEndpoint);

        // This ContractDescription instance must be used for both endpoints in this case
        ContractDescription description = ContractDescription.GetContract(typeof(IDiagnosticService));

        // Create JSON webHTTP Binding            
        WebHttpBinding webhttpbinding = new WebHttpBinding();
        string jsonURI = internalEndpointAddress + "/json";
        EndpointAddress jsonEndpointAddress = new EndpointAddress(new Uri(jsonURI));
        ServiceEndpoint jsonEndpoint = new ServiceEndpoint(description, webhttpbinding, jsonEndpointAddress);
        jsonEndpoint.Behaviors.Add(new WebHttpBehavior());


        // Create WSHTTP Binding          
        WSHttpBinding wsHttpBinding = new WSHttpBinding();
        string soapURI = internalEndpointAddress + "/soap";
        EndpointAddress soapEndpointAddress = new EndpointAddress(new Uri(soapURI));
        ServiceEndpoint soapEndpoint = new ServiceEndpoint(description, wsHttpBinding, soapEndpointAddress);



        container.AddFacility<WcfFacility>(f => f.CloseTimeout = TimeSpan.Zero)
                 .Register(Component.For<IDiagnosticService>()
                    .ImplementedBy<DiagnosticService>()
                    .Named("DiagnosticService")
                    .LifestyleTransient()
                    .AsWcfService(new DefaultServiceModel()
                                    .Hosted()
                                    .AddEndpoints(WcfEndpoint.FromEndpoint(jsonEndpoint))
                                    .AddEndpoints(WcfEndpoint.FromEndpoint(soapEndpoint))
                                    .PublishMetadata(o => o.EnableHttpGet())));

这篇关于指定每个端点的Castle WCF集成设施端点行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆