WCF服务器和客户端之间通过LAN进行通信失败

时间:2014-11-29 13:59:31

标签: c# .net windows wcf

我正在尝试使用Microsoft WCF在客户端和服务器之间进行通信 - 在C#中使用netTcpBinding,服务器作为Windows服务运行。服务器作为单个PC在我的虚拟LAN上运行。但是通信始终失败并出现错误:

An unhandled exception of type 'System.ServiceModel.Security.SecurityNegotiationException' occurred in mscorlib.dll

Additional information: The server has rejected the client credentials.

在localhost上一切正常。客户端也从此IP地址下载ServiceReference。

服务器app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WCFHostService.MyServiceBehavior">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="WCFHostService.MyServiceBehavior" name="WCFServiceHost.MyService">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
              name="NetTcpBindingEndpoint" contract="WCFServiceHost.IMyService">
          <identity>
            <dns value="" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
            name="MexTcpBindingEndpoint" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://10.0.0.1:8523/WCFTestService" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <bindings>
      <netTcpBinding>
        <binding name = "netTcpBinding">
          <security mode="None"/>
        </binding>
      </netTcpBinding>
    </bindings>
  </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>
            <netTcpBinding>
                <binding name="NetTcpBindingEndpoint" />
            </netTcpBinding>
        </bindings>
        <client>
            <endpoint address="net.tcp://10.0.0.1:8523/WCFTestService" binding="netTcpBinding"
                bindingConfiguration="NetTcpBindingEndpoint" contract="ServiceReference1.IMyService"
                name="NetTcpBindingEndpoint">
                <identity>
                    <dns value="&#xD;&#xA;          " />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>

我认为可能在配置文件的安全设置中存在问题。有什么问题吗?在服务器系统上的TCPView中,我只看到MyService的远程地址&#34;他的本地计算机名称&#34;而不是*(全部)。谢谢你的回复。

0 个答案:

没有答案