[英]WCF service endpoint not accessible in self-hosting
我创建了一个由DummyService
实现的IDummyService
合同。 我正在尝试使用以下配置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>
运行正常并启动这些端点的服务主机代码。 但是,当我尝试访问以下端点时,由于Page isn't working
在Chrome浏览器中Page isn't working
,我收到了错误消息。
http://localhost:8733/DummyService/
http://localhost:8733/mex/
但是,我可以访问页面http://localhost:8733/
我不明白为什么会这样。
我认为端点地址是该端点的address
条目,附加到主机的baseaddress
有什么想法我做错了吗?
谢谢。
您已经应用了behavior behaviorConfiguration =“ MEX”属性,但没有使用它,出于安全原因,您需要启用WCF中默认为false的元数据发现。
<serviceBehaviors>
<behavior name = "MEX">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
现在,当您浏览http:// localhost:8733 / DummyService /和http:// localhost:8733 / mex /时 ,浏览器中将显示一个空白页面,而不是默认错误页面。
另外,如果要测试net.tcp终结点,则可以使用WCFtestclient.exe。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.