Search code examples
wcfconfigurationwcf-configurationservicebehavior

WCF - How to attach serviceBehaviors to WCF endpoint (no <service> tag)


I am consuming a third party WCF service and its config is below (a portion of it). I wanted to assign serviceBehaviors to endpoint, but there is no <service> tag here. In this case, how do you assign 'serviceBehaviors'?

<client>
  <endpoint address="https://something/someservice.asmx" binding="customBinding" bindingConfiguration="ABCBinding" contract="Democlient.Soap" name="Soap" behaviorConfiguration="SoapEndpointB" />
</client>
<behaviors>
  <endpointBehaviors>
    <behavior name="SoapEndpointB">
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="SoapServiceB">
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
      <serviceMetadata httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

Solution

  • You assign serviceBehaviors to WCF server endpoints, not to client endpoints. You would have to request the 3rd party WCF service host add the service behaviors you seek if you need them changed.