我有一个嵌入到 Windows 服务中的 WCF 服务。它绑定到本地主机,但它也接受来自这种 URL 的连接 - “http://ip:port/ServiceName”,我怎样才能将它隐藏起来并只允许来自本地主机的连接。
这是我的服务配置
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="Test.Service.ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="Test.Service.ServiceBehavior" name="Test.Service.TestService">
<endpoint address="localhost" binding="wsHttpBinding" contract="Test.Service.IService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/MyService/service" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>