简体   繁体   中英

WCF: One service with two behaviours (behaviorConfiguration)

I have a service having two Behaviours. One is for throttling and another is for Metadata exchange. How to enable Both in a service? When we enable first, Second gets disabled and vice-versa.

My behaviour names are MexBehaviour and ThrottlingBehaviour. Service works fine for one of the following line but not both:

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

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

How to specify both at a time?

A behavior configuration specifies what the behavior of a service would look like. To combine behaviors, you would create a behavior with these combinations, and then point to that behavior

If you are working with the WCF Metadata and throttling behaviors, to combine them you would create a new behavior like this

<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>

then in your service point to this configuration

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM