Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WCF安全实现错误_Wcf_Security - Fatal编程技术网

WCF安全实现错误

WCF安全实现错误,wcf,security,Wcf,Security,这是我得到的错误: 无法处理该消息。这很可能是因为该行动http://tempuri.org/xxxxxx'不正确,或者因为消息包含无效或过期的安全上下文令牌,或者因为绑定之间不匹配。如果服务因不活动而中止通道,则安全上下文令牌将无效。为了防止服务过早中止空闲会话,请增加服务端点绑定上的接收超时 这是我的web.config副本: <?xml version="1.0"?> <configuration> <system.web> <comp

这是我得到的错误:

无法处理该消息。这很可能是因为该行动http://tempuri.org/xxxxxx'不正确,或者因为消息包含无效或过期的安全上下文令牌,或者因为绑定之间不匹配。如果服务因不活动而中止通道,则安全上下文令牌将无效。为了防止服务过早中止空闲会话,请增加服务端点绑定上的接收超时

这是我的web.config副本:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
      </assemblies>
    </compilation>
  </system.web>  
   <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="wsUserNameToken">
          <security mode="TransportWithMessageCredential">
            <transport clientCredentialType="None"/>
            <message clientCredentialType="UserName"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service name="ServiceName" behaviorConfiguration="userNameTokenBehavior">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsUserNameToken" name="userNameTokenService" contract="ContractName"/>
        <endpoint address="mex" binding="wsHttpBinding" bindingConfiguration="wsUserNameToken" name="MexHttpsBindingEndpoint" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="userNameTokenBehavior">
          <serviceMetadata httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
          <serviceCredentials>
            <serviceCertificate findValue="xxxxxxxxxxxxx" x509FindType="FindByThumbprint" storeLocation="LocalMachine" storeName="My" />
            <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="xxxxx.xxxxx.UsernameValidator, App_Code"/>
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>  
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
 </configuration>


有人能找出我的配置文件有什么问题吗?

在wsHttpBinding元素中,可以添加ReceiveTimeout属性并将其值设置为较大值并进行检查。以下是一个示例:

<binding name="wsUserNameToken" closeTimeout="00:01:00" openTimeout="00:01:00"
          receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
          transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
          useDefaultWebProxy="true" allowCookies="false">

还可以尝试在您的服务上启用,并检查日志以确定请求失败的原因


希望有帮助。

检查元数据绑定。绑定应该是mexHttpsBinding,而不是wsHttpBinding

WCF是客户端和服务器之间的舞蹈。还可以包括客户端配置。服务名称属性和端点协定属性应为完全限定名称。还可以对您的服务进行跟踪,以了解故障原因。这显然不是解决问题的方法。WCF绑定的问题几乎总是不是由超时问题引起的。