Host WCF Service in WAS

Before doing these steps; host your WCF service in IIS. I assumed that you already did that. And my target here is to host the service in WAS with net.tcp port 🙂 thank you.

Installing WAS (you can ignore these steps if WAS already installed)

1.Control Panel >> Programs.
2.Under Programs and Features, click Turn Windows Features On And Off.
3.Select Windows Process Activation Service and its sub-features.
4.Select Microsoft .NET Framework 3.51 and its sub features.
5.Click OK.
Let’s Configure the Host Environment for the WCF Service to Support the TCP Protocol:

1.  Start inetmgr as administrator.

2.  Default site >> Right click >> Edit Bindings.

3.  If you have installed WAS correctly, it should list the default protocol bindings for the Web site, as shown in the following image:

Hosting WCF TCP Port

4.  Expand the Default Web Site item, and then click on your service (which is already hosted in IIS) application.

5.  Advanced Settings.

6.  In the Enabled Protocols add comma then net.tcp

Host WCF Service in WAS

7.  Click OK.

Now, Lets Configure the Client Application to Connect by Using the TCP Protocol.

  1. Test the service on the browser (copy paste the url to your browser) and make sure if it works.
  2. Now, Regenerate the proxy using the svcutil.exe
  3. Open the new output.config
  4. Get the new TCP Binding & endpoint from the file and add it to your client app.
    (The green bubbles below shows the net.tcp configuration).

5. Open the main() method in your client application and paste this line below:

ProductsServiceClient proxy = new ProductsServiceClient();

6. Run your app.

7. !!! What was that! Crash!

You have more than one endpoint available; you must specify which endpoint to use.

8. Just add your TCP endpoint’s name to your proxy constructor.

ProductsServiceClient proxy = new ProductsServiceClient(“NetTcpBinding_IService”);

TCP Endpoint name taken from:

10. Another Crash!! Go to the next step to solve that :).

11.Very important notes here:

  1. In most cases your machine will block the default TCP port; which is 808.
  2. For testing turn off your firewall.
  3. Add the port to the trusted ports:
  4. And to make sure that your Firewall will not block your port (if you do not turn it off); do the following:

i.     Go to Windows Firewall with advanced security.

ii.     And finally; add the port to Inbound Rules and Outbound Rules.