2017-08-02 66 views
0

我在Windows服务中托管HTTP WCFService,在本地网络中它完美地工作,但是如果客户端在另一个网络中并尝试与de公共IP连接不起作用。Windows服务中的主机HTTP WCF服务

配置文件:

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

    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 
    <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="WCFService.ServiceBehavior"> 
     <endpoint address="" binding="wsHttpBinding"  
      contract="WCFService.ServiceContract"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" 
     contract="IMetadataExchange" /> 
    <host> 
     <baseAddresses> 
     <add baseAddress="http://localhost:80/WCFService/service/" /> 
     </baseAddresses> 
    </host> 
    </service> 
</services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, 
      set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/> 
     <serviceDebug includeExceptionDetailInFaults="False" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
    </system.serviceModel> 

</configuration> 
+0

可能是防火墙? – FakeCaleb

+0

您正在显示服务器部件的web.config。显示客户端的web.config。 – Piotr

+0

可能重复https://stackoverflow.com/questions/7505126/how-to-set-up-my-wcf-service-to-be-able-to-be-accessed-by-remote-clients – Dmitry

回答

0

我怀疑,当你给这样的配置:由于的locahost使用

<add baseAddress="http://localhost:80/WCFService/service/" /> 

,将在环回地址被监听。将其更改为实际的公共IP地址(即不是127.0.0.1)或服务器名称,然后再次检查。