zoukankan      html  css  js  c++  java
  • WCF 服务器已拒绝客户端凭据

    将 WCF 服务器和客户端分别部署到不同机器上,可能会触发如下异常。

    未处理 System.ServiceModel.Security.SecurityNegotiationException   Message="服务器已拒绝客户端凭据。"   Source="mscorlib"


    解决方法,就是调整服务器端 Binding 的安全方式,比如设为 "None"。

    NetTcpBinding binding = new NetTcpBinding(); binding.Security.Mode = SecurityMode.None;
    ServiceHost host = new ServiceHost(typeof(MyService)); host.AddServiceEndpoint(typeof(IService), binding, "net.tcp://192.168.10.112:8081");
    ServiceMetadataBehavior metadata = new ServiceMetadataBehavior(); metadata.HttpGetUrl = new Uri("http://192.168.10.112:8080"); metadata.HttpGetEnabled = true; host.Description.Behaviors.Add(metadata);
    host.Open();


    或者在配置文件中设置。

    <?xml version="1.0" encoding="utf-8" ?> <configuration>   <system.serviceModel>     <bindings>       <netTcpBinding>         <binding name="NewBinding0">           <security mode="None" />         </binding>       </netTcpBinding>     </bindings>     <behaviors>       <serviceBehaviors>         <behavior name="NewBehavior">           <serviceMetadata httpGetEnabled="true" httpGetUrl="http://192.168.10.112:8080" />         </behavior>       </serviceBehaviors>     </behaviors>     <services>       <service behaviorConfiguration="NewBehavior" name="Learn.Library.WCF.MyService">         <endpoint address="net.tcp://192.168.0.112:8081" binding="netTcpBinding"           bindingConfiguration="NewBinding0" contract="Learn.Library.WCF.IService">         </endpoint>       </service>     </services>   </system.serviceModel> </configuration>
  • 相关阅读:
    (Eclipse) Selection does not contain main type
    Spring Web Flow 学习笔记(2)-流程的组件
    Spring Web Flow 学习笔记(1)
    快速排序java实现
    二路归并排序
    剪切板
    Java中空白final
    对象引用和对象
    Java复用类
    Experimenrs on Foursquare
  • 原文地址:https://www.cnblogs.com/iack/p/3561255.html
Copyright © 2011-2022 走看看