0

This article doesn't use the standard WCF Service Library project template in VS2010, so apparently it lacks some things that might make it easier to host on IIS.

Can somebody please provide the steps necessary (and as much details as you care to include) to take this particular WCF solution to the stage where it is hosted on IIS 7?

Thanks.

Sam
  • 2,663
  • 10
  • 41
  • 60
  • Do you want to learn on how to host a WCF service on IIS 7? – Rajesh Apr 20 '12 at 14:35
  • Yes, but specific to the solution created by the article above because it doesn't use the WCF Service Library project template so many things have to be done manually in addition to whatever needs to be done to host the service in IIS 7... but basically yes. – Sam Apr 20 '12 at 14:40
  • Would it not be simple to use the VS2012 template and then host it in IIS. Refer to his link on how to host a wcf service on IIS : http://msdn.microsoft.com/en-us/library/ms733766.aspx – Rajesh Apr 20 '12 at 14:50
  • Please see my answer below hope that helps. – Rajesh Apr 20 '12 at 15:11

1 Answers1

1
  1. Create a folder at C:\intepub\wwwroot\Test
  2. The contents of the above folder would be as below a. bin folder b. a .svc file c. web.config file

Now from the article once your build the service class library project it would generate a .dll file that needs to be copied over to the bin folder.

Now create a .svc file with the below content:

<%@ServiceHost language=c# Debug="true" Service="TConvertAS.Services.TempConverter "%>

Now your web.config should look as below:

<?xml version="1.0" encoding="utf-8"?>
<configuration>     
  <system.web>    
    <compilation debug="true" targetFramework="4.0">
    </compilation>
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />    
  </system.web>
  <system.serviceModel>   
    <bindings>      
      <basicHttpBinding>
        <binding>
          <security mode="None">            
          </security>
        </binding>                  
    <services>
      <service name="TConvertAS.Services.TempConverter">
        <endpoint address="" binding="basicHttpBinding" name="Service1" contract="TConvertAS.Contracts.ITempConverter" />                        
      </service>      
    </services>    
    <behaviors>      
      <serviceBehaviors>        
        <behavior>
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>        
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />        
  </system.serviceModel>  
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>            
  </system.webServer>  
</configuration>

Once you have the above just make sure about the app pool under which your application needs to be configured to run under.

Now just right click on the .svc file under the virtual directory and click browse to see the WCF service page.

(OR)

Instead of creating a new folder under c:\intepub\wwwroot you can directly map the virtual directory to your WCF service class library project and add the svc and web.config files to your WCF service class library project.

Rajesh
  • 7,766
  • 5
  • 22
  • 35