Hosting a WCF service in IIS keeps us bound to use HTTP based transport. As of IIS version 7 we can use the Windows Process Activation Service (WAS) to provide non-HTTP based transports like TCP for our services.
First we need to enable WAS as a Windows Feature.
Also under Microsoft .Net Framework node select both WCF HTTP and Non-HTTP Activation. The later gives us access to endpoint protocols like TCP and MSMQ.
Open the Internet Information Services (IIS) Manager and add a webapplication pointing to the website created in the previous example. Click the binding action to add a new site binding for net.tcp on port 8888, or whatever port you find appropriate.
Also make sure the webapplication supports net.tcp by choosing advanced settings and set the Enabled Protocols property to “http,net.tcp”. These settings are stored in the applicationHost.config file.
And finally add a netTcpBinding endpoint to the Web.config of our service. Nothing fancy here.
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> <identity impersonate="true" /> </system.web> <system.serviceModel> <bindings /> <services> <service name="WcfServiceLibrary.ExtensibleData.TransactionService"> <endpoint address="Transaction" binding="basicHttpBinding" bindingConfiguration="" contract="WcfServiceLibrary.ExtensibleData.ITransactionService" /> <endpoint address="" binding="netTcpBinding" bindingConfiguration="" contract="WcfServiceLibrary.ExtensibleData.ITransactionService" /> </service> </services> <behaviors> <serviceBehaviors> <behavior name=""> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true" /> </system.webServer> </configuration>
If we browse to our WSDL definition at http://localhost/TransactionService.svc?wsdl we see two ports. One for HTTP and one for TCP. We are now effectively exposing a TCP endpoint to our Transaction service from within IIS with WAS.
<wsdl:service name="TransactionService"> <wsdl:port name="BasicHttpBinding_ITransactionService" binding="tns:BasicHttpBinding_ITransactionService"> <soap:address location="http://localhost/TransactionService.svc/Transaction"/> </wsdl:port> <wsdl:port name="NetTcpBinding_ITransactionService" binding="tns:NetTcpBinding_ITransactionService"> <soap12:address location="net.tcp://l040.ada-ict.nl:8888/TransactionService.svc"/> <wsa10:EndpointReference> <wsa10:Address>net.tcp://l040.ada-ict.nl:8888/TransactionService.svc</wsa10:Address> <Identity xmlns="http://schemas.xmlsoap.org/ws/2006/02/addressingidentity"> <Spn>host/L040.ada-ict.nl</Spn> </Identity> </wsa10:EndpointReference> </wsdl:port> </wsdl:service>




