【问题标题】:WCF: One service with two behaviours (behaviorConfiguration)WCF:一个服务有两种行为(behaviorConfiguration)
【发布时间】:2014-09-08 15:04:17
【问题描述】:

我的服务有两种行为。一个用于节流,另一个用于元数据交换。如何在服务中启用两者?当我们第一次启用时,第二次被禁用,反之亦然。

我的行为名称是 MexBehaviour 和 ThrottlingBehaviour。服务适用于以下行之一,但不能同时适用:

 <service behaviorConfiguration="ThrottlingBehaviour" 
                   name="ThrottlingService.ThrottlingService">

 <service behaviorConfiguration="MexBehaviour" 
                   name="ThrottlingService.ThrottlingService">

如何同时指定两者?

【问题讨论】:

    标签: wcf servicebehavior


    【解决方案1】:

    行为配置指定服务的行为应该是什么样子。要组合行为,您可以使用这些组合创建一个行为,然后指向该行为

    如果您正在使用 WCF 元数据和限制行为,将它们结合起来,您将创建一个像这样的新行为

    <behaviors>
      <serviceBehaviors>
        <behavior name="metathrottle">
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceThrottling maxConcurrentCalls="100"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    

    然后在你的服务中指向这个配置

    <service behaviorConfiguration="metathrottle" name="ThrottlingService.ThrottlingService">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-23
      • 1970-01-01
      • 1970-01-01
      • 2015-08-18
      • 2011-03-08
      • 2011-04-25
      • 1970-01-01
      • 2013-01-03
      相关资源
      最近更新 更多