代码之家  ›  专栏  ›  技术社区  ›  Eben Roux

Castle WCF设施-服务行为

  •  4
  • Eben Roux  · 技术社区  · 16 年前

    如何使用Castle WcfFacility并使其使用标准Wcf配置文件设置?

    container.Register(
    AllTypes.Pick()
        .FromAssemblyNamed("{ServicesAssembly}") // <-- service assembly here
        .If(type => type.Name.EndsWith("Service"))
        .WithService.FirstInterface()
        .Configure(configurer => configurer.LifeStyle.Transient)
        .Configure(configurer => configurer.Named(configurer.Implementation.Name))
        .Configure(configurer => configurer.ActAs(new DefaultServiceModel()))
    );
    

    我收到以下错误:

    服务{name}没有应用程序(非基础结构)终结点。

    如果我离开:

    .Configure(configurer => configurer.ActAs(new DefaultServiceModel()))
    

    似乎配置中的行为被忽略了。

    这里的正确用法是什么?

    2 回复  |  直到 16 年前
        1
  •  6
  •   Eben Roux    16 年前

    我是这样注册的:

    container.Register(
    AllTypes.Pick()
        .FromAssemblyNamed("{ServicesAssembly}") // <-- service assembly here
        .If(type => type.Name.EndsWith("Service"))
        .WithService.FirstInterface()
        .Configure(configurer => configurer.LifeStyle.Transient)
        .Configure(configurer => configurer.Named(configurer.Implementation.Name))
        .Configure(configurer => configurer.ActAs(new DefaultServiceModel().Hosted()))
    );
    

    这个 托管() 有没有表明我是托管服务;否则,WCF设施似乎会尝试托管它们,从而导致端口冲突。

    名称 配置文件中服务的 与温莎指定的名称相同。

        2
  •  0
  •   Krzysztof Kozmic    16 年前

    你就快到了。

    你需要这个:

    .ActAs(new DefaultClientModel(WcfEndpoint.FromConfiguration( <<key In Configuration>> )));
    
    推荐文章