我有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
才能生效,指定localhost
而不是Machine IP address
我只能从本地机器连接到我的服务。
答案 0 :(得分:0)
在基地址上使用0.0.0.0,它应该适用于系统上的每个网络接口,无论其地址如何。 localhost不起作用,因为它调用DNS查找,其值为127.0.0.1,仅为本地服务。