0

我的服务具有以下配置,运行良好。当我需要使用 TransportWithMessageCredential 安全模式更改 wsHttpBinding 中 MaxClockSkew 的值时,就会出现问题。

如何更改此配置中的 MaxClockSkew 值?

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="HttpsService_wsHttpBinding" closeTimeout="01:10:00"
          openTimeout="01:10:00" receiveTimeout="Infinite" sendTimeout="Infinite"
          maxBufferPoolSize="999999999" maxReceivedMessageSize="99999999">
          <readerQuotas maxDepth="999999999" maxStringContentLength="999999999"
            maxArrayLength="999999999" maxBytesPerRead="999999999" maxNameTableCharCount="999999999" />
          <reliableSession inactivityTimeout="Infinite" enabled="true" />
          <security mode="TransportWithMessageCredential">
            <message clientCredentialType="UserName" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service name="WcfServiceApp.Service1">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="HttpsService_wsHttpBinding"
          name="wsHttpEndPoint" contract="CommonTypes.IService" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="Custom"
              customUserNamePasswordValidatorType="CommonTypes.CustomValidator, CommonTypes" />
          </serviceCredentials>
          <dataContractSerializer maxItemsInObjectGraph="2147483646" />
          <bufferedReceive maxPendingMessagesPerChannel="2147483647" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <diagnostics wmiProviderEnabled="true">
      <messageLogging
           logEntireMessage="true"
           logMalformedMessages="true"
           logMessagesAtServiceLevel="true"
           logMessagesAtTransportLevel="true"
           maxMessagesToLog="3000"
       />
    </diagnostics>
  </system.serviceModel>
4

1 回答 1

2

根据这篇文章中的信息,您似乎无法更改maxClockSkew标准(即 WCF 提供的)绑定上的属性,您需要使用自定义绑定。像这样的东西:

<system.serviceModel>
  <bindings>
    <customBinding>
      <binding name="HttpsService_wsHttpBinding" 
               closeTimeout="01:10:00"
               openTimeout="01:10:00" 
               receiveTimeout="Infinite" 
               sendTimeout="Infinite">
        <reliableSession inactivityTimeout="Infinite" 
                         enabled="true" />
        <security authenticationMode="SecureConversation">
          <secureConversationBootstrap authenticationMode="UserNameOverTransport" />
          <localServiceSettings maxClockSkew="00:30:00" />
        </security>
        <textMessageEncoding messageVersion="soap12">
          <readerQuotas maxDepth="999999999" 
                        maxStringContentLength="999999999"
                        maxArrayLength="999999999" 
                        maxBytesPerRead="999999999"
                        maxNameTableCharCount="999999999" />
        </textMessageEncoding> 
        <httpsTransport maxBufferPoolSize="999999999"
                        maxReceivedMessageSize="99999999" />
      </binding>
    <customBinding>
  </bindings>
</system.serviceModel>

请注意,时钟偏差是在元素属性的<security>部分中设置的(在本示例中为 30 分钟)。自定义绑定起初可能有点吓人和/或混淆,但仔细检查上述示例并使用 MSDN 会有所帮助。<localServiceSettings>maxClockSkew

CustomBindings是一个很好的起点,请注意文章指出了元素的特定顺序。

有关配置部分元素和属性的概述,您可以查看此处:<customBinding>.

我相信,您还需要将maxClockSkew客户端自定义绑定上的属性设置为与服务相同的值。

于 2015-09-02T14:44:03.297 回答