tags:

views:

149

answers:

1

Hi,

I've been building a WCF app behind 3 projects (contract,implementation,client) I've hosted my service as a console app with basic HTTP binding. I'm now ready to move it to IIS. However, the tutorial for creating a .svc file shows it actually implementing the contract - but I already have an implementation. How do I just redirect to that implementation or should I be adding a .svc file to my existing implementation project?

Hope that's clear enough.

Cheers, Rob

+3  A: 

I normally add the SVC file in, and the ServiceHost will point to the same class that you would when you create a new instance of a ServiceHost from Code.

So your CommandLine host might look like:

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

And your .svc file would look like:

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

So now you have your app hostable in IIS and also from the commandline.

I normally just knock up the svc file when I am ready to deploy.

Paul.

Kinlan
Correct answer, but in his case he'll likely be referencing a library, which will require specifying the assembly in the service attribute:Service="CoolService.CoooolEndpoint, CoolServiceAssembly"
Anderson Imes
That is a good spot, I copied some of it from my code which is in the same assembly.
Kinlan