Migrate WCF Service from Test Console Application to IIS

I am creating a WCF application in 3 projects (contract, implementation, client). I hosted my service as a console application with basic HTTP binding. Now I'm ready to move it to IIS. However, the tutorial on creating the .svc file shows that it actually fulfills the contract, but I already have an implementation. How can I simply redirect to this implementation, or add the .svc file to an existing implementation project?

Hope this is clear enough.

Cheers, Rob

+1


a source to share


1 answer


I usually add an SVC file and the ServiceHost will point to the same class you would create when creating a new ServiceHost instance from code.

So your CommandLine host might look like this:

using (ServiceHost serviceHost = new ServiceHost(typeof(CoolService.CoooolEndpoint)))
{

      

And your .svc file will look like:



<%@ ServiceHost Language="C#" Debug="false" Service="CoolService.CoooolEndpoint" %>

      

So now you have an application that can be used in IIS as well as from the command line.

I usually just run the svc file when I'm ready to deploy.

Paul.

+3


a source







All Articles