繁体   English   中英

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

[英]Does WCF windows service support intranet connection?

我是WCF的初学者。 我试图将WCF服务器托管在IIS中,并且可以成功访问另一台计算机上的服务。 当我更改为在Windows Service中托管此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

binding="netTcpBinding"

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM