[英]Displaying the IP address of the local machine in order to connect outside the network?
[英]Succeed to connect my WCF service only from local machine unless machine ip address is specified instead of localhost
我有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,无论其地址如何,它都应适用于系统上的每个网络接口。 localhost不起作用,因为它调用DNS查找,该查找的结果为127.0.0.1,仅在本地提供。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.