wcf System.ServiceModel.Security.SecurityNegotiationException示例Andrew Troelsen

时间:2014-07-09 07:07:52

标签: wcf

我读了Andrew Troelsen第25章“Windows Communication Foundation简介”中的一本书。并制作了她的例子。当我在你的计算机上运行客户端时 - 就好了。当我试图从另一台计算机上调用我的服务时 - 我得到了以下错误: System.ServiceModel.Security.SecurityNegotiationException。 是什么原因? 主机的App.config:

<configuration>
<system.serviceModel>   
<services>
<service name = "MagicEightBallServiceLib.MagicEightBallService" >
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8080/MagicEightBallService"/>
<add baseAddress ="net.tcp://localhost:8099/MagicEightBallService"/>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding openTimeout = "00:00:30" />
</basicHttpBinding>
<netTcpBinding>
<binding closeTimeout = "00:00:15" />
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled = "true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>   

客户端的App.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup> 
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IEightBall" />
</basicHttpBinding>
<netTcpBinding>
<binding name="NetTcpBinding_IEightBall" />
</netTcpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8080/MagicEightBallService"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IEightBall"
contract="ServiceReference1.IEightBall" name="BasicHttpBinding_IEightBall" />
<endpoint address="net.tcp://localhost:8099/MagicEightBallService"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IEightBall"
contract="ServiceReference1.IEightBall" name="NetTcpBinding_IEightBall">
<identity>
<userPrincipalName value="TK238A-DEBIAN\Debian" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>

1 个答案:

答案 0 :(得分:0)

尝试更改

<userPrincipalName value="TK238A-DEBIAN\Debian" />

<servicePrincipalName value="host/localhost" /> 

在客户端配置文件中。