WCF Windows服务是否支持Intranet连接?

问题描述 投票:0回答:1

我是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>
c# wcf intranet
1个回答
1
投票

如果是内联网服务,如果您选择部署为Windows服务,那么请考虑使用netTcpBinding

binding="netTcpBinding"

另外,请考虑使用机器的正确IPv4地址而不是localhost

© www.soinside.com 2019 - 2024. All rights reserved.