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>
  • 相关阅读:
    案例十:shell编写nginx服务启动程序
    Linux在实际中的应用
    案例九:shell脚本自动创建多个新用户,并设置密码
    数据架构的演变
    第一个Struts2程序
    关于eclipse导入Tomact报404的问题
    单选框 RadioButton
    EditText编辑框
    Button控件的三种点击事件
    1319: 同构词
  • 原文地址:https://www.cnblogs.com/iack/p/3561255.html
Copyright © 2011-2022 走看看