Can I use netTcpBinding for WCF services hosted outside of IIS?

My WCF service is hosted as a Windows managed service, so I don't know if I can still use netTcpBinding. I tried to follow a few tutorials on MSDN, but for some reason my service always starts when I switch from basicHttpBinding. Perhaps there are additional steps that services must perform outside of IIS?

+3
source share
2 answers

Yes, you can host the WCF service using netTcpBinding outside of IIS, in a Windows service, or even in a console application if you want.

Here is an example configuration file:

<system.serviceModel>
  <behaviors>
    <serviceBehaviors>
      <behavior name="ServiceBehavior">
        <serviceMetadata />
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <services>
    <service behaviorConfiguration="ServiceBehavior"
             name="XX.XX.Service">
      <endpoint address=""
                binding="netTcpBinding"
                bindingConfiguration="BindingConfiguration"
                contract="XX.XX..IService" />
      <endpoint address="mex"
                binding="mexTcpBinding"
                contract="IMetadataExchange" />
      <host>
        <baseAddresses>
          <add baseAddress="net.tcp://localhost:8731/XXService" />
        </baseAddresses>
      </host>
    </service>
  </services>
  <bindings>
    <netTcpBinding>
      <binding
        name="BindingConfiguration">
        <security mode="None" />
      </binding>
    </netTcpBinding>
  </bindings>
</system.serviceModel>

[change]

Problems with your configuration file:

  • base address is http, not net.tcp
  • - mexHttpBinding metTcpBinding
  • - Windows, . "" , .
  • httpGetEnabled
  • , , ,
+4

, , , .

:

<services>
   <service name="Server.FileService" ...
      <host>
         <baseAddresses>
            <add baseAddress="http://localhost:8000/Test/file"/>
         </baseAddresses>
      </host>
      <endpoint address="" binding="netTcpBinding" contract="Server.IFile" />
      <endpoint address="mex" binding="mexHttpBinding" ...

net.tcp net.tcp://, http://.

baseAddress, . baseAddress

      <endpoint address="net.tcp://localhost:8001/Test/file" ..

( , 8000)

+2

All Articles