【问题标题】:WCF service reject with error The server has rejected the client credentialsWCF 服务拒绝错误服务器已拒绝客户端凭据
【发布时间】:2014-08-22 07:57:27
【问题描述】:

按照this 指南,我尝试使用TCP 在Windows 服务中托管WCF service。 这在我的计算机上运行良好,但是在同一网络中的其他计算机上安装此服务时出现错误:服务器已拒绝客户端凭据 我尝试禁用防火墙但仍然出现相同的错误(并且服务正在运行......) 从客户端添加服务参考工作正常并识别服务。 这是我的 app.config 文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>
      <service name="WcfServiceLibrary1.Service1">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
          contract="WcfServiceLibrary1.IService1">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://192.168.0.100:8523/Service1 " />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

192.168.0.100是服务器机器IP地址。

【问题讨论】:

  • 当您运行 WinForm 应用程序(客户端)时,您在什么凭据下运行它?您可能需要在具有管理员权限的域帐户下运行它。

标签: c# .net wcf


【解决方案1】:

尝试将此配置用于 tcp 绑定:

<bindings>
  <netTcpBinding>
    <binding name="customTcpBinding" maxReceivedMessageSize="20480000" transferMode="Streamed" >
      <security mode="None"></security>
    </binding>
  </netTcpBinding>
</bindings>

【讨论】:

  • 那解决不了问题。 OP 将获得绑定不匹配,因为安全性不匹配。该服务将使用netTcpBinding 的默认安全模式,即“传输”。
  • 我需要把这部分放在哪里?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-02-06
  • 1970-01-01
  • 1970-01-01
  • 2012-11-15
  • 1970-01-01
  • 2017-10-15
  • 1970-01-01
相关资源
最近更新 更多