Hosting A Service as A WCF Service

89 Views Asked by At

I have two .cs files in one i will specify the Interfaces, and in another file i will implement the interfaces. Now i want to host Service as a WCF Service on IIS. In another way How to host the already existing service(Functionality) as a WCF Service. Thanks in advance.

1

There are 1 best solutions below

0
On

You have several options:

  1. put your two *.cs files into your App_Code directory in a web site and let ASP.NET compile then as needed. You will need to create a service file something like this:

    YourService.svc

    <%@ ServiceHost Language="C#" Debug="true" 
        Service="YourService" CodeBehind="~/App_Code/YourService.cs" %>
    
  2. put your two *.cs files into a separate class-library project and compile them into a DLL which you put into the \bin directory in your web site/web application. You will need to create a service file something like this:

    YourService.svc

    <%@ ServiceHost Language="C#" Debug="true" Service="YourService"  %>
    

This service file tells the IIS runtime how to handle incoming requests for the http://(yourserver)/(virtualdirectory)/YourService.svc URL.

Now, once everything is setup, you should be able to connect to your service at the service URL using a tool like the WCF Test Client to send SOAP requests (and receive back responses)