首页 > 其他 > 详细

解决WCF 调用方未由服务器进行身份验证或消息包含无效或过期的安全上下文令牌

时间:2016-07-29 21:22:53      阅读:437      评论:0      收藏:0      [点我收藏+]

错误描述:

1. WCF:调用方未由服务器进行身份验证

2. 无法处理消息。这很可能是因为操作“http://tempuri.org/ISCCLSvc/GetCarriersByWareHouse”不正确,或因为消息包含无效或过期的安全上下文令牌,或因为绑定之间出现不匹配。如果由于未处于活动状态导致服务中止了该通道,则安全上下文令牌无效。若要防止服务永久中止闲置会话,请增加服务终结点绑定上的接收超时。

3.或并发测试时,高并发出现问题2,实际案例:公司测试部门结果是并发到50就会出现问题2错误,并且平均响应时间也会很慢

 

解决后结果:

接口测试并发100无问题,并且平均响应时间减小5倍时间!

 

解决方法:

主要修改红色文本区域

 

<system.serviceModel>
   <bindings>
      <wsHttpBinding>
        <binding name="NoneSecurity"
          maxBufferPoolSize="12000000" maxReceivedMessageSize="12000000" useDefaultWebProxy="false">
          <readerQuotas maxStringContentLength="12000000" maxArrayLength="12000000"/>
          <security mode="None"/>
        </binding>
      </wsHttpBinding>
    </bindings>

    <services>
    <service name="WcfService2.Service1" behaviorConfiguration="WcfService2.Service1Behavior">
     <!-- Service Endpoints -->
     <endpoint address="" binding="wsHttpBinding" bindingConfiguration="NoneSecurity" contract="WcfService2.IService1">
      <!-- 
              部署时,应删除或替换下列标识元素,以反映
              在其下运行部署服务的标识。删除之后,WCF 将
              自动推导相应标识。
          -->
      <identity>
       <dns value="localhost"/>
      </identity>
     </endpoint>
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    </service>
   </services>
   <behaviors>
    <serviceBehaviors>
     <behavior name="WcfService2.Service1Behavior">
      <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点-->
      <serviceMetadata httpGetEnabled="true"/>
      <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息-->
      <serviceDebug includeExceptionDetailInFaults="false"/>
     </behavior>
    </serviceBehaviors>
   </behaviors>
</system.serviceModel>
</configuration>

客户端将security配置改为<security mode="None"/>

 

 

详细错误信息:

 
<p></p><p>System.ServiceModel.Security.MessageSecurityException was unhandled
  Message=An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.
  Source=mscorlib
  StackTrace:
    Server stack trace: 
       at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.ProcessReply(Message reply, TimeSpan timeout, SecurityProtocolCorrelationState correlationState)
       at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at ApiStressTest.SCCL.ISCCLSvc.GetCarriersByWareHouse(TransModel tm)
       at ApiStressTest.SCCL.SCCLSvcClient.GetCarriersByWareHouse(TransModel tm) in D:\SCCL\ApiTest.new\ApiStressTest\Service References\SCCL\Reference.cs:line 198
       at ApiStressTest.ServiceWrapper.ServiceAPIWrapperMethod(Object stateInfo) in D:\SCCL\ApiTest.new\ApiStressTest\SCCLProgram.cs:line 416
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart(Object obj)
  InnerException: System.ServiceModel.FaultException
       Message=无法处理消息。这很可能是因为操作“http://tempuri.org/ISCSvc/GetHouse”不正确,或因为消息包含无效或过期的安全上下文令牌,或因为绑定之间出现不匹配。如果由于未处于活动状态导致服务中止了该通道,则安全上下文令牌无效。若要防止服务永久中止闲置会话,请增加服务终结点绑定上的接收超时。
       InnerException:

</p><p>
</p>

 

解决WCF 调用方未由服务器进行身份验证或消息包含无效或过期的安全上下文令牌

原文:http://www.cnblogs.com/yeye518/p/5719603.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!