- IIS
- Direct object creation
- Locally hosted instance of the WCF service (using .Net's WebServiceHost class)
It all starts with an Interface definition:

Which is implemented by

Testing Version method using IIS/Cassini
To access this Service in IIS/Cassini, we call the SetRouteTable method from the Global.asax.cs Application_Start callback:

Which sets the AdminRest as the route (i.e. url path) into the Admin_REST service

Since we have the help pages enabled (on web.config)

We can view a wsdl-type-helper page at http://localhost:3187/AdminREST/help


And invoke the Version method using http://localhost:3187/AdminREST/Version

Testing Version method directly
Inside a VisualStudio 2010 Test Project:


When executed


Testing Version method using a WCF Host
A more interesting/powerful technique to host the WCF service temporarily on a local port, and access the service via HTTP.

The code above is used by this Unit Test that opens and closes the WCF port during its execution:

Here is the output of the the CheckWebServicesHost test:

To make this work (and to help debugging) I added/used the DNS entry local (instead of localhost) , which allowed me to view the WCF traffic in Fiddler:

Note that the local DNS mapping needs to defined in the system32/etc/hosts file:

Another change that I had to do, was to give my current user account, the ability to bind to the 20000 port.
This was done using the HttpNamespaceManager.zip tool available from the AddressAccessDeniedException: HTTP could not register URL http://+:8080/<…> MSDN Article.


Here are couple posts that explain why this last step was required:
- Unit Testing WCF ServiceHost fails within a TFS Integration Build
- System.ServiceModel.AddressAccessDeniedException: HTTP could not register URL
- getting System.ServiceModel.AddressAccessDeniedException on Vista for WCF service
- System.ServiceModel.AddressAccessDeniedException: HTTP could not register URL