0

我有一个具有一个 http 端点的 WCF 服务,我想添加另一个具有不同绑定的 http 端点地址。该服务未托管在 IIS 中,因此设置 multipleSiteBindingsEnabled 是没有用的。

我正在尝试这样的事情。

<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

    <services>
            <service behaviorConfiguration="ServiceBehaviorConfiguration"
             name="ServerService">
                <endpoint address="http://localhost:6732/ServerService" binding="webHttpBinding" behaviorConfiguration="webby"
         contract="IClientAppContract">
                    <identity>
                        <dns value="localhost" />
                    </identity>
                </endpoint>
                <endpoint address="http://localhost:800/ServerService" binding="basicHttpBinding"
         contract="IClientAppContract">
                    <identity>
                        <dns value="localhost" />
                    </identity>
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
                <host>
                    <baseAddresses>
                        <add baseAddress="http://localhost:800/ServerService" />
                        <add baseAddress="http://localhost:6732/ServerService" />
                    </baseAddresses>
                </host>
            </service>
        </services>
</system.serviceModel>
4

2 回答 2

0

您可以创建两个服务,每个服务都有自己不同的 baseAddress,但它们的内部端点是相同的。

于 2012-06-06T22:05:56.027 回答
0

尝试如下所示的配置。它通过单个端口公开多个端点,但我确信 WCF 支持这种配置模式。

    <services>
        <service behaviorConfiguration="ServiceBehaviorConfiguration"
                 name="ServerService">
            <endpoint address=""
                      binding="webHttpBinding"
                      behaviorConfiguration="webby"
                      contract="IClientAppContract">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
            <endpoint address="basic"
                      binding="basicHttpBinding"
                      contract="IClientAppContract">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
            <endpoint address="mex"
                      binding="mexHttpBinding"
                      contract="IMetadataExchange" />
            <host>
                <baseAddresses>
                    <add baseAddress="http://localhost:800/ServerService" />
                </baseAddresses>
            </host>
        </service>
    </services>
于 2012-06-05T13:27:34.697 回答