1

浏览“WCF4.0 中的新增功能”教程。第一个练习是在没有任何配置的情况下设置服务。然后,您进行一些配置以提供服务元数据。简单的东西。

我现在尝试做的是扩展配置以在不同的端口上公开相同的服务合同 - 在本例中为http://localhost:9001/test

这是我的配置...

<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior name="WCF4Configuration.EchoServiceBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service behaviorConfiguration="WCF4Configuration.EchoServiceBehavior" name="WCF4Configuration.EchoService">
            <endpoint address="" binding="wsHttpBinding" contract="WCF4Configuration.IEchoService">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>                              
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          <endpoint address="http://localhost:9001/test" binding="wsHttpBinding" contract="WCF4Configuration.IEchoService"/>
        </service>
    </services>
</system.serviceModel>

但是我尝试连接到这个我收到机器主动拒绝连接的消息。为什么这不起作用?我可以在 wcftestclient 中使用什么地址来显示服务?

4

1 回答 1

0

尝试:

<services>
        <service behaviorConfiguration="WCF4Configuration.EchoServiceBehavior" name="WCF4Configuration.EchoService">
            <endpoint address="" binding="wsHttpBinding" contract="WCF4Configuration.IEchoService">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>                              
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          <endpoint address="" binding="wsHttpBinding" contract="WCF4Configuration.IEchoService">
           <host>
            <baseAddresses>
              <add baseAddress="http://localhost:9001/test/" />
            </baseAddresses> 
          </endpoint>
        </service>
</services>
于 2011-04-05T20:02:24.493 回答