浏览“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中使用哪个地址来显示服务?
答案 0 :(得分: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>