WCF windows 服务是否支持内网连接?

Does WCF windows service support intranet connection?

我是 WCF 的初学者。我试图在 IIS 中托管我的 WCF 服务器,并且可以成功访问另一台机器上的服务。当我在 Windows 服务中更改为托管此 WCF 服务器时,我可以在本地访问,但在另一台机器上失败。 WCF 支持这个吗?如果有任何示例演示如何在 Intranet 中使用 windows 服务托管 WCF,将不胜感激!

我在两台机器上都关闭了防火墙。 以下是我使用的服务配置:

<system.serviceModel>
  <services>
    <service behaviorConfiguration="Service" name="TestService.Test">
      <endpoint address="basic" binding="basicHttpBinding" name="basic" contract="TestService.ITest">
        <identity>
          <dns value="localhost"/>
        </identity>
      </endpoint>
      <endpoint address="mex" binding="mexHttpBinding" name="mex" contract="IMetadataExchange"/>
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:8080/TestService/"/>
        </baseAddresses>
      </host>
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="Service">
        <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
        <serviceDebug includeExceptionDetailInFaults="false"/>
      </behavior>
    </serviceBehaviors>
  </behaviors>

@Rahul,谢谢你的帮助。最后我成功了。在这里我把我的配置贴出来,希望能帮助遇到类似问题的人。 将我的服务器配置更改为:

<system.serviceModel>
<bindings>
  <netTcpBinding>
    <binding name="tcpConfig">
      <security mode="None" />
    </binding>
  </netTcpBinding>
</bindings>
<services>
  <service behaviorConfiguration="Service" name="TestService.Test">
    <endpoint address="net.tcp://localhost:8081/Test" binding="netTcpBinding"
      bindingConfiguration="tcpConfig" name="tcp" contract="TestService.ITest" />
    <endpoint address="mex" binding="mexHttpBinding" name="mex" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8080/TestService/" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="Service">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

下面是我的客户端配置,运行 在另一台机器上:

<system.serviceModel>
    <bindings>
        <netTcpBinding>
            <binding name="tcp">
                <security mode="None" />
            </binding>
        </netTcpBinding>
    </bindings>
    <client>
        <endpoint address="net.tcp://192.168.209.132:8081/TestService" binding="netTcpBinding"
            bindingConfiguration="tcp" contract="TestServiceReference.ITest"
            name="tcp" />
    </client>
</system.serviceModel>

如果它是 Intranet 服务并且您选择部署为 windows 服务然后考虑使用 netTcpBinding like

binding="netTcpBinding"

此外,请考虑使用您计算机的正确 IPv4 地址,而不是 localhost