Ronnie Overby
Ronnie Overby

Reputation: 46460

Trouble referencing WCF CustomBinding in web.config

I have created a custom binding to replace the wsHttpBinding that I was using before so that I could set the maxClockSkew setting (http://blog.salamandersoft.co.uk/index.php/2009/01/wcf-wshttpbinding-and-clock-skew/). The binding is created in web.config, not in code.

But I'm not sure how to tell my service to use this binding.

Here is my binding:

  <customBinding>
    <binding name="myWSHttpBinding">
      <transactionFlow transactionProtocol="WSAtomicTransactionOctober2004" />
      <security defaultAlgorithmSuite="Default" authenticationMode="SecureConversation"
          requireDerivedKeys="true" securityHeaderLayout="Strict" includeTimestamp="true"
          keyEntropyMode="CombinedEntropy" messageProtectionOrder="SignBeforeEncryptAndEncryptSignature"
          messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"
          requireSecurityContextCancellation="true" requireSignatureConfirmation="false">
        <localClientSettings cacheCookies="true" detectReplays="true"
            replayCacheSize="900000" maxClockSkew="00:05:00" maxCookieCachingTime="Infinite"
            replayWindow="00:05:00" sessionKeyRenewalInterval="10:00:00"
            sessionKeyRolloverInterval="00:05:00" reconnectTransportOnFailure="false"
            timestampValidityDuration="00:05:00" cookieRenewalThresholdPercentage="60" />
        <localServiceSettings detectReplays="true" issuedCookieLifetime="10:00:00"
            maxStatefulNegotiations="128" replayCacheSize="900000" maxClockSkew="00:05:00"
            negotiationTimeout="00:01:00" replayWindow="00:05:00" inactivityTimeout="00:02:00"
            sessionKeyRenewalInterval="15:00:00" sessionKeyRolloverInterval="00:05:00"
            reconnectTransportOnFailure="false" maxPendingSessions="128"
            maxCachedCookies="1000" timestampValidityDuration="00:05:00" />
        <secureConversationBootstrap defaultAlgorithmSuite="Default"
            authenticationMode="UserNameForSslNegotiated" requireDerivedKeys="true"
            securityHeaderLayout="Strict" includeTimestamp="true" keyEntropyMode="CombinedEntropy"
            messageProtectionOrder="SignBeforeEncryptAndEncryptSignature"
            messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"
            requireSecurityContextCancellation="true" requireSignatureConfirmation="false">
          <localClientSettings cacheCookies="true" detectReplays="true"
              replayCacheSize="900000" maxClockSkew="00:05:00" maxCookieCachingTime="Infinite"
              replayWindow="00:05:00" sessionKeyRenewalInterval="10:00:00"
              sessionKeyRolloverInterval="00:05:00" reconnectTransportOnFailure="true"
              timestampValidityDuration="00:05:00" cookieRenewalThresholdPercentage="60" />
          <localServiceSettings detectReplays="true" issuedCookieLifetime="00:15:00"
              maxStatefulNegotiations="128" replayCacheSize="900000" maxClockSkew="00:05:00"
              negotiationTimeout="00:01:00" replayWindow="00:05:00" inactivityTimeout="00:02:00"
              sessionKeyRenewalInterval="15:00:00" sessionKeyRolloverInterval="00:05:00"
              reconnectTransportOnFailure="true" maxPendingSessions="128"
              maxCachedCookies="1000" timestampValidityDuration="00:05:00" />
        </secureConversationBootstrap>
      </security>
      <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
          messageVersion="Default" writeEncoding="utf-8">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      </textMessageEncoding>
      <httpTransport manualAddressing="false" maxBufferPoolSize="2147483647"
          maxReceivedMessageSize="2147483647" allowCookies="false" authenticationScheme="Anonymous"
          bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
          keepAliveEnabled="true" maxBufferSize="2147483647" proxyAuthenticationScheme="Anonymous"
          realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
          useDefaultWebProxy="true" />
    </binding>
  </customBinding>

Upvotes: 1

Views: 1918

Answers (2)

Ronnie Overby
Ronnie Overby

Reputation: 46460

    <endpoint address="" binding="customBinding" bindingConfiguration="myWSHttpBinding"
      contract="IYourService" />

Upvotes: 2

user595010
user595010

Reputation:

Simply reference your binding by name using bindingConfiguration attribute of service's endpoint element.

Upvotes: 2

Related Questions