0

消息包含无效的过期安全上下文令牌或因为绑定之间不匹配

问题是,客户端和服务器时间相差几秒钟。Web 服务一切正常,除非在客户端/服务器关闭的几秒钟之间进行调用。所以,如果调用,客户端时间是6:00:58,服务器时间是6:01:01,就会出现上面的错误。

我添加了代码来捕获异常,并再次尝试调用,但不断收到此消息。

我已经在客户端/服务器上同步了时间,但它们最终会在几秒钟后不同步。

有没有人有任何想法?

这是重要的网络配置的一部分(客户端/服务器之间的一切都相同):

  <service behaviorConfiguration="WebServiceBehavior" name="WebService.TestService">
    <endpoint 
        address="" 
        binding="wsHttpBinding" 
        bindingConfiguration="WSHttpBinding_Service" 
        contract="WebService.ITestService">
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="./WebService/TestService/" />
      </baseAddresses>
    </host>
  </service>    

</services>
<bindings>

  <wsHttpBinding>
    <binding name="WSHttpBinding_Service" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="1000000" maxReceivedMessageSize="1000000" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="false" allowCookies="false">
      <readerQuotas maxDepth="900000" maxStringContentLength="900000" maxArrayLength="900000" maxBytesPerRead="900000" maxNameTableCharCount="900000" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
      <security mode="Message">
        <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
        <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true" />
      </security>
    </binding>
  </wsHttpBinding>

</bindings>   

 <behaviors>
    <serviceBehaviors>
      <behavior name="WebServiceBehavior">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>
<system.web>
    <customErrors mode="On" />
    <identity impersonate="false" />
    <authentication mode="Forms" />
</system.web>
4

1 回答 1

2

您可以配置一个自定义绑定来模拟wsHttpBinding,让您maxClockSkew将安全设置增加到错误范围之外。见这篇文章。太糟糕了,你不能直接在现有的wsHttpBinding.

于 2009-11-08T01:11:49.193 回答