将WCF Web服务绑定到特定的网络接口/ IP

sun*_*ide 8 wcf networking binding web-services interface

在具有多个网卡的计算机上,我需要将WCF Web服务绑定到特定的网络接口.似乎默认是在所有网络接口上绑定.

该机器有两个带IP 192.168.0.10和IP的网络适配器192.168.0.11.我有一个绑定的Apache运行,需要运行webservice .(由于外部环境,我无法选择其他端口.)192.168.0.10:80192.168.0.11:80

我尝试了以下方法:

string endpoint = "http://192.168.0.11:80/SOAP";
ServiceHost = new ServiceHost(typeof(TService), new Uri(endpoint));
ServiceHost.AddServiceEndpoint(typeof(TContract), Binding, "");
// or: ServiceHost.AddServiceEndpoint(typeof(TContract), Binding, endpoint);
Run Code Online (Sandbox Code Playgroud)

但它不起作用; netstat -ano -p tcp总是显示监听的web服务0.0.0.0:80,这是所有接口(如果我得到了正确的话).当我首先启动Apache时,它正确地绑定到另一个接口,这反过来阻止WCF服务绑定到"all".

有任何想法吗?

Mat*_*rey 2

我们在我的工作场所也遇到了类似的问题,当我偶然发现你的帖子时,我们正在对此进行研究。我还没有机会尝试它,但计划当我们有机会时尝试:绑定上有一个“hostNameComparisonMode”,当设置为“Exact”时,应该始终遵循您的设置。(如果找不到匹配项,默认情况下允许使用通配符。)

如果您有机会在我之前尝试此操作,请告诉我结果。否则,我会更新我的答案并让您知道!