首页 > 解决方案 > 一个监听多个地址的 WCF 服务(仅限配置)

问题描述

我有一个托管 WCF 服务的现有 Windows 服务(所以没有 IIS)。

此时它正在监听一个地址:http://xxx/service.svc。

现在我想让它也听第二个地址:http://yyy/service.svc。

我只能修改配置,不能修改源。该服务在 .NET Framework 4.5.2 下运行。

我的配置:

    <services>
        <service behaviorConfiguration="All" name="MyNamespace.MyService">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="myBindingConfig" contract="MyNamespace.IMyService"/>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            <host>
                <baseAddresses>
                    <add baseAddress="http://xxx/service.svc"/>
                </baseAddresses>
            </host>
        </service>
    </services>

到目前为止我已经尝试过:

标签: wcfwindows-servicesapp-config

解决方案


推荐阅读