我创建了由IDummyService
实施的DummyService
合同。我正在使用以下配置尝试self-host
此服务:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<system.serviceModel>
<services>
<service name="DummyService.DummyService" behaviorConfiguration="MEX">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/" />
</baseAddresses>
</host>
<endpoint address="DummyService"
binding="basicHttpBinding"
contract="DummyService.IDummyService"/>
<endpoint address="net.tcp://localhost:8734/DummyService/"
binding="netTcpBinding"
bindingConfiguration = "TransactionalTCP"
contract="DummyService.IDummyService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<netTcpBinding>
<binding name = "TransactionalTCP" transactionFlow = "true"/>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name = "MEX">
<serviceMetadata/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
运行良好的服务主机代码并启动这些端点。但是,当我尝试访问以下端点时,我在Chrome浏览器中收到Page isn't working
错误。
http://localhost:8733/DummyService/
http://localhost:8733/mex/
但是,我可以访问页面http://localhost:8733/
我不明白为什么会这样。
我认为端点地址是附加到主机address
baseaddress
条目
任何想法我做错了什么?
感谢。
答案 0 :(得分:0)
您已应用属性 behaviorConfiguration =&#34; MEX&#34; 但未使用它,因此出于安全原因,您需要启用默认情况下在WCF中为false的元数据发现。
<serviceBehaviors>
<behavior name = "MEX">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
现在,当您浏览http://localhost:8733/DummyService/和http://localhost:8733/mex/时,浏览器中将显示空白页,而不是默认错误页。
如果您想测试 net.tcp 端点,也可以使用WCFtestclient.exe。