dhl:The request for security token could not be satisfied because authentication failed. 调用方未由服务进行身份...

The request for security token could not be satisfied because authentication failed.

[SecurityNegotiationException: 调用方未由服务进行身份验证。]

 

解决方法:
在服务端配置文件添加<binding>配置验证<Security=“none”>,客户端配置验证<Security=“none”>
ContractedBlock.gif ExpandedBlockStart.gif Code
<!--dhl-->
    
<system.serviceModel>
        
<services>
            
<service behaviorConfiguration="PingCoCMS.Service.Implementation.GuestBookServiceBehavior"
              name
="PingCoCMS.Service.Implementation.GuestBookService">
                
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="NoneSecurity" contract="PingCoCMS.Service.Interfaces.ServiceContracts.IGuestBookService">
                    
<identity>
                        
<dns value="localhost" />
                    
</identity>
                
</endpoint>
                
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            
</service>

            
<service behaviorConfiguration="PingCoCMS.Service.Implementation.CMSServiceBehavior"
              name
="PingCoCMS.Service.Implementation.CMSService">
                
<endpoint address="" binding="wsHttpBinding"  bindingConfiguration="NoneSecurity"  contract="PingCoCMS.Service.Interfaces.ServiceContracts.ICMSService">
                    
<identity>
                        
<dns value="localhost" />
                    
</identity>
                
</endpoint>
                
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            
</service>
            
        
</services>

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


        
<behaviors>
            
<serviceBehaviors>
                
<behavior name="PingCoCMS.Service.Implementation.GuestBookServiceBehavior">
                    
<serviceMetadata httpGetEnabled="true"/>
                    
<serviceDebug includeExceptionDetailInFaults="true"/>
                
</behavior>

                
<behavior name="PingCoCMS.Service.Implementation.CMSServiceBehavior">
                    
<serviceMetadata httpGetEnabled="true"/>
                    
<serviceDebug includeExceptionDetailInFaults="true"/>
                
</behavior>
            
</serviceBehaviors>
        
</behaviors>        
    
</system.serviceModel>


 
资料:

一直在一台电脑上同时搞WCF的服务和客户端,今天在另外一台电脑上调用,发现了一个新的问题"调用方未由服务进行身份验证",

在网上查了大量的资料,也没有发现有人说明白其中的原因,只是发现了一篇解决的办法,但是个人感觉不是最佳的方案,所以还在探索中.

发现的解决的办法中提到,在服务端和客户端分别将安全验证设置成"none"就可以了,自己试了几遍也没成功.但是从理论上是行的通的.

 

另外发现了一个解决办法,不知道有没有其它的见解

将 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.0.112:8081");

ServiceMetadataBehavior metadata = new ServiceMetadataBehavior();
metadata.HttpGetUrl = new Uri("http://192.168.0.112:8080");
metadata.HttpGetEnabled = true;
host.Description.Behaviors.Add(metadata);

host.Open();
或者在配置文件中设置。


 

转载于:https://www.cnblogs.com/dudu837/archive/2009/08/25/1553410.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值