0

У меня есть следующая конфигурация для моей службы, которая работает нормально. Проблема возникает, когда мне нужно изменить значение MaxClockSkew в wsHttpBinding с помощью режима безопасности TransportWithMessageCredential.Настройка MaxClockSkew в wsHttpBinding с TransportWithMessageCredential Security Mode

Как изменить значение 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> 

ответ

2

на основе информации, содержащейся в этом post, по-видимому, вы не можете изменить 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> с атрибутом <localServiceSettings> элемента maxClockSkew (в данном примере 30 минут). Пользовательские привязки могут быть немного запугивающими и/или запутанными вначале, но будет полезно внимательное изучение приведенного выше примера и использование MSDN.

CustomBindings - хорошее место для начала и обратите внимание, что в статье указывается конкретный порядок элементов.

Подробнее об элементах и ​​атрибутах раздела конфигурации вы можете посмотреть здесь: <customBinding>.

Вам также необходимо установить свойство maxClockSkew на пользовательскую привязку клиента с тем же значением, что и сервис.

 Смежные вопросы

  • Нет связанных вопросов^_^