Web服务错误 - 无法处理消息。这很可能是因为动作''不正确或因为

时间:2009-11-07 23:52:24

标签: wcf security token

  

邮件包含无效的过期安全上下文令牌,或者因为绑定之间存在不匹配

问题是,客户端和服务器时间只有几秒钟。 Web服务都可以正常工作,除非在客户端/服务器关闭的几秒钟之间进行调用。因此,如果进行了呼叫,并且客户端时间是6:00:58,服务器时间是6:01:01,则​​会出现上述错误。

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

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

有没有人有任何想法?

以下是重要的Web配置的一部分(客户端/服务器之间的所有内容都相同):

  <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>

1 个答案:

答案 0 :(得分:2)

您可以配置模仿wsHttpBinding的自定义绑定,以便将安全设置的maxClockSkew增加到错误范围之外。见this article。太糟糕了,你不能直接在现有的wsHttpBinding上进行。

相关问题