2

I seem to be in a catch-22. My IIS website has multiple ports open for HTTP (80 and 8080 - unfortunate I can't change that) and I want to expose a WCF service only as net.tcp. Here is the relevant config area:

<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>

That allows me to navigate to http://localhost/MyService.svc?WSDL and it shows only the net.tcp endpoint. The problem is that instead of CustomName:8083, I see MyComputerName:8083. I read that if you have multiple site bindings enabled it ignores the baseAddressPrefixFilters which makes sense.

If I disable the multiple site bindings I get the error, This collection already contains an address with scheme http ... you can fix the problem by ... specifying 'system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters'

If I uncomment the HTTP lines I get the error Service ... has zero application (non-infrastructure) endpoints.

So what's the magic combination to only expose TCP and use CustomName when I have multiple HTTP ports open?

Edit: Not exactly what I'm after, but the following does change the WSDL output if I access it from http://CustomName/MyService.svc?WSDL. It's meant more for load-balancing scenarios and I can't fix it to one address.

      <useRequestHeadersForMetadataAddress>
        <defaultPorts>
          <add scheme="net.tcp" port="8083" />
        </defaultPorts>
      </useRequestHeadersForMetadataAddress>
Nelson Rothermel
  • 9,436
  • 8
  • 62
  • 81
  • Would this be of any help? http://stackoverflow.com/questions/561823/wcf-error-this-collection-already-contains-an-address-with-scheme-http – Valamas Jan 22 '14 at 05:27
  • or this? http://social.msdn.microsoft.com/Forums/vstudio/en-US/1256f72d-f078-4267-9910-03b2c9364391/wcfnettcp-adapter-this-collection-already-contains-an-address-with-scheme-nettcp-there-can-be?forum=wcf – Valamas Jan 22 '14 at 05:27
  • Valamas, the links mention basically what I've tried. I guess I don't understand why `multipleSiteBindingsEnabled="false"` and specifying `baseAddressPrefixFilters` for HTTP doesn't work. If that worked then I would be closer, but the WSDL would probably expose the HTTP endpoint which I don't want. – Nelson Rothermel Jan 22 '14 at 15:02
  • Since we're only using this service internally I was able to get away without having the correct WSDL and for public-facing services `useRequestHeadersForMetadataAddress` may be close enough, but I'll leave the question up in case someone is able to solve this. – Nelson Rothermel Jan 28 '14 at 18:57

0 Answers0