title: Host WCF service in WAS
body: <p>I need some help with hosting a WCF service in WAS.
  I hosted the service ok in IIS and accessed over basicHttp and wsHttp binding.
  But it seems I miss something when trying to host it in WAS and access over tcp/ip.</p>
  
  <p>I need to configure it for access over tcp on port 10000.</p>
  
  <p>I enabled WCF activation for Non-HTTP in Windows Features</p>
  
  <p>The service is published under default web site, application mywcfapp</p>
  
  <p>I created a BAT file to enable net.tcp binding on port 10000 on default web site and mywcfapp as below:</p>
  
  <pre><code>%windir%\system32\inetsrv\appcmd.exe set site "Default Web Site" -+bindings.[protocol='net.tcp',bindingInformation='10000:*']
  %windir%\system32\inetsrv\appcmd.exe set app "Default Web Site/mywcfapp" /enabledProtocols:http,net.tcp
  </code></pre>
  
  <p>The web.config is</p>
  
  <pre><code>&lt;services&gt;
    &lt;service name="MyWcfService"&gt;
      &lt;clear /&gt;
      &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"
        listenUriMode="Explicit" /&gt;
  
      &lt;endpoint address="net.tcp://localhost:10000/mywcfapp/mywcfapp.svc"
        binding="netTcpBinding" bindingConfiguration="PortSharingBinding" contract="MyApp.IService" /&gt;
      &lt;endpoint address="net.tcp://localhost:10000/mywcfapp/mywcfapp.svc"
        binding="netTcpBinding" bindingConfiguration="PortSharingBinding" contract="MyApp.IService" /&gt;
  
    &lt;/service&gt;
  &lt;/services&gt;
  
  &lt;bindings&gt;
    &lt;netTcpBinding&gt;
      &lt;binding name="PortSharingBinding" portSharingEnabled="true"&gt;
        &lt;security mode="None" /&gt;
      &lt;/binding&gt;
    &lt;/netTcpBinding&gt;
  &lt;/bindings&gt;
  </code></pre>
  
  <p>However, it seems I cannot access the service.</p>
  
  <p>When I try to access the service with WcfTestClient with the uri </p>
  
  <pre><code>net.tcp://localhost:10000/mywcfapp/mywcfapp.svc/mex
  </code></pre>
  
  <p>I get the following error</p>
  
  <pre><code>&lt;Fault xmlns="http://www.w3.org/2003/05/soap-envelope"&gt;
  &lt;Code&gt;
      &lt;Value&gt;Sender&lt;/Value&gt;
      &lt;Subcode&gt;&lt;Value xmlns:a="http://www.w3.org/2005/08/addressing"&gt;a:DestinationUnreachable&lt;/Value&gt;
      &lt;/Subcode&gt;
  &lt;/Code&gt;
  &lt;Reason&gt;&lt;Text xml:lang="ro-RO"&gt;
      The message with To 'net.tcp://localhost:10000/mywcfapp/mywcfapp.svc/mex' 
      cannot be processed at the receiver, due to an AddressFilter mismatch 
      at the EndpointDispatcher.  
      Check that the sender and receiver's EndpointAddresses agree.
  &lt;/Text&gt;&lt;/Reason&gt;
  &lt;/Fault&gt;
  </code></pre>
  
  <p>If I try to connect with url (w/o specifying port) </p>
  
  <pre><code>net.tcp://localhost/OneTest.Service/OneTest.Service.svc/mex
  </code></pre>
  
  <p>I get the error (kept only significant part)</p>
  
  <pre><code>Could not connect to net.tcp://localhost/mywcfapp/mywcfapp.svc/mex. 
  The connection attempt lasted for a time span of 00:00:02.0041146. 
  TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:808.     
  No connection could be made because the target machine actively refused it 127.0.0.1:808
  </code></pre>