1

我有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="WCFServiceHostingInWinService.MySampleWCFService">
        <endpoint
          name="ServiceHttpEndPoint"
          address="" 
          binding="basicHttpBinding"
          contract="WCFServiceHostingInWinService.IMySampleWCFService">
        </endpoint>
        <endpoint
          name="ServiceMexEndPoint"
          address="mex"
          binding="mexHttpBinding"
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://192.168.0.192:8733/MySampleWCFService/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the value below to false before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

该服务安装在多台机器上,但在每台机器上,我需要将其更改 <add baseAddress="http://192.168.0.192:8733/MySampleWCFService/" />为相关IP address的才能工作,当指定时,我只能从本地机器连接到我的服务。localhostMachine IP address

4

1 回答 1

0

在基地址上使用 0.0.0.0,它应该适用于系统上的每个网络接口,无论其地址如何。localhost 不起作用,因为它调用 DNS 查找,其计算结果为 127.0.0.1,它仅在本地服务。

于 2013-10-22T17:34:30.777 回答