In my last post i wrote about a new Visual Studio Extension Template which i had developed for jump starting WCF REST Service based development targeting Visual Web Developer 2010 Express edition. I did receive a 4 star rating from 1 reviewer and he said “Great Work”. That really pumped me up and then wanted to do some more. So here i am with another release of a new extension template. Read on to see what it is.

The extension template i wrote for VWD gives you a jump start in developing a WCF REST Service which is hosted by a Web Server i.e. using IIS of course. What if you wanted to try out a self hosting WCF REST service. That necessity lead me to create one more Visual Studio extension template. I am calling this template as “VC# WCF REST Service Template”. At this moment as i write this blog post, the extension is live on Visual Studio Gallery site. Here is the link to that : As said previously i wanted to support the community which uses the Express edition so this extension is targeted for Visual C# 2010 Express edition only.

So lets see how to use this template step by step:

Getting the template:

Fire up the Visual C# 2010 Express. Go to extension manager and search for “VC# WCF”. You will see the search results show the extension. Click on Download and the extension will be installed.


After installation, you can click on Installed Extension on the left hand panel and you should see this extension listed there. See the screen shot below:


Using the Template:

Once you have finished the above step its now time to use the template. Select File > New Project. In the templates section you will see the new project template option. See the screen shot below:


Give the new project a name and location and click Ok. At this moment you have a new Self Hosted WCF Rest Service project.

Description of the Solution:

Now lets see the solution that just got created because of the above step. Here is a screen shot of the solution:


The solution is broken down into 4 Parts:

  • WCF REST Service Contract
    This project contains the contracts for the WCF REST Service we will be building. Its always a good practice to bundle your contracts into its own assemblies.
  • WCF REST Service
    This project is the actual WCF REST Service implementation. This has a reference to WCF REST Service Contract.  
  • WCF REST Service Host
    This project is the console host which will host our WCF REST Service. This is a simple console project which reference WCF REST Service and WCF REST Service Contract.

  • WCF REST Service Client
    This is a test client for our WCF REST Service. This client has a reference to WCF REST Service Contract. Using ChannelFactory this establishes communication to our WCF REST Service and executes the operation.

Couple of gotchas:

  • The service is hosted on port 9117. I have picked some random port number. If you want to change the port number of your choice then look in WCF REST Service Host and WCF REST Service Client.
  • Since we are running on a random port, you will face namespace reservation problem. So before running the application please do the following:
  • Open a command prompt as “Administrator”.
  • Run the following command. Note this is for WIN 7.
  • netsh http add urlacl url=http://+:9117/ user=<your domain\your user name>

If everything goes well i.e. build succeeded and you have done the namespace reservation – then the Server console should look like the following:


Then if you start the client, you will see the following result:


One thing to note here is – the client uses the Service Contract and ChannelFactory to communicate to the server. If you look at the service contract itself all the operation have UriTemplate defined. Meaning you can access them in a RESTful way. So once the server is up, open a browser for e.g. Internet Explorer and hit the URL http://localhost:9117. This address has been mapped to GetCollection method on the contract using the UriTemplate and this method can server HTTP GET method.

In this template – the client communicating with the server using Contract & Channel factory and also ability to access the same endpoints using the Browser showcases 2 facets of the WCF REST Support i.e. if you have your methods designed RESTfully without any specific HTTP parameters – it can support both the non browser consumption meaning a WCF client or a non WCF client PLUS any browser based consumption too.

So we learned something new today. I am super excited about this subject. Will continue to explore more on this grounds. So stay tuned.

Till next time, Happy Coding. Code with Passion. Decode with Patience.

  • Very to the point explanation – loved the process and way you explain.

    • Pinal Sir

      Thanks for the comments. Thnx for the observation. It makes a great deal coming from you who has finished 1700 posts :)

  • Great post man. I would definitely try this out.

    Must be one of the quicker approach to deal with REST. Thanx man.

    • Abhishek

      Thanks for the comments. Appreciate it that you took time to go through this.

  • This is really great work and looking forward your upcoming extension as well ! Thanks for sharing !

    • Abhijit

      Thanks for the comments. Keep giving me feedbacks :)

  • Anonymous

    Interesting one! Liked the way you presented the content.
    Will try this tonight.

    Also, loved your quote… ‘Code with Passion. Decode with Patience’ like anything :)

    • Pranav

      Thnks for the comments dude. glad you liked it.

  • This extension supports only Visual C# 2010 Express Edition :(

    Any version for Visual Studio 2010 !?

    Thank you!!!

  • Chethan

    hi this is chethan.. from MIT collage i was attended ur seminor in NIE collage .. it was nice.. and i tried the program u told.. i sended it to ur facebook account.. plz check it and reply me if it is correct or not.. my mail

  • Dariusz Adrychowski

    After digging around for some while- finally something so useful. Very good template. Thank You. 

  • Hi, your post on WCF for VS EE is great. It helped me start learning WCF. I have some suggestion to this post however. As this template represent REST flavor of WCF maybe it is worth do add new project – client calling REST by url using old plain HTTP model (as if calling REST from other client i.e. PHP). I have made that extension for me, but I have problem how to provide authentication (have you any WORKING solution? Even basic authent. made do). So an the end greetings for Poland, may force of programming be with you, always!