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>