WCF无文件配置

时间:2014-01-22 03:32:17

标签: c# wcf tcp

我似乎陷入困境22。我的IIS网站有多个端口为HTTP打开(80和8080 - 不幸的是我无法改变它),我想将WCF服务仅作为net.tcp公开。这是相关的配置区域:

<protocolMapping>
  <clear />
  <!--<add scheme="http" binding="basicHttpBinding" />-->
  <add scheme="net.tcp" binding="netTcpBinding" />
</protocolMapping>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
  <baseAddressPrefixFilters>
    <!--<add prefix="http://CustomName:8080" />-->
    <add prefix="net.tcp://CustomName:8083" />
  </baseAddressPrefixFilters>
  <serviceActivations>
    <add relativeAddress="MyService.svc" service="Namespace.MyServiceClass" />
    ...
  </serviceActivations>
</serviceHostingEnvironment>

这允许我导航到http://localhost/MyService.svc?WSDL,它只显示net.tcp端点。问题是,而不是CustomName:8083,我看到MyComputerName:8083。我读到如果你启用了多个站点绑定,它会忽略baseAddressPrefixFilters,这是有道理的。

如果我禁用多个网站绑定,我会收到错误This collection already contains an address with scheme http ... you can fix the problem by ... specifying 'system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters'

如果我取消注释HTTP行,我会收到错误Service ... has zero application (non-infrastructure) endpoints

那么,当我打开多个HTTP端口时,只暴露TCP并使用CustomName的神奇组合是什么?

编辑:不完全是我所追求的,但如果我从http://CustomName/MyService.svc?WSDL访问它,以下内容确实会更改WSDL输出。对于负载平衡方案而言,这意味着更多,我无法将其修复为一个地址。

      <useRequestHeadersForMetadataAddress>
        <defaultPorts>
          <add scheme="net.tcp" port="8083" />
        </defaultPorts>
      </useRequestHeadersForMetadataAddress>

0 个答案:

没有答案