none
Hosting a WCF Service Library using IIS RRS feed

  • Question

  • Most of what I hear online is that its best to use the WCF Service Library because it is more flexible and can be used with a variety of hosts. Yet i also notice that most websites that use the WCF Service Library also end up co-opting the WCF Service Application to get the service to run on IIS. Is this the only way?  Can it be done without using the WCF Service Application? (I'm not against this option, but I'm trying to learn and understand whether there are other options or not. It seems to be implied that there must be but I can't find them.)

    I'm using VS 2010 and the .NET 3.5 framework, but I'm also interested in later frameworks as well. (I won't be stuck here forever.)

    I've heard that there are limitations to using the WCF Service Library. Nigel Shaw made a comment to that effect here: http://stackoverflow.com/questions/1423065/what-is-the-purpose-of-wcf-service-library

    Thanks for any information you can provide!

    Ok, I did find a couple of articles that seem to use an ASP.NET Web Application and tells you how to create a text file for the svc file.

    This article: http://debugmode.net/2010/12/25/wcf-service-library-creating-hosting-and-consuming-wcf-service-with-wcf-service-library-project-template/  

    and this one: http://danielvanwyk.wordpress.com/2010/04/30/create-host-and-consume-a-wcf-service-using-the-wcf-service-library-template-in-visual-studio-2008/ 

    But what I still don't understand is why is the ASP.NET Application still needed? And If i add a svc file does it get placed in the wwwroot directory, which is where the WCF Service Application appears to put its svc file?

    thanks


    Wednesday, November 13, 2013 5:14 AM

Answers

  • Basically since it is a library, that is all it is. I need to do more to be able to host it.

    http://stackoverflow.com/questions/19944606/combining-wcf-service-library-and-wcf-service-application

    A WCF Service Library has to be hosted in order to be used - you can host it in IIS, a Windows Service or some self-hosted option (like a console app, WinForm, WPF, etc).

    In the last two links you provide, they're demonstrating how to host the library in an ASP.NET service application, but you don't have to use that project template to host it. It's simply one option out of several.

    You can create an IIS-hosted implementation of your class library without using a VS project template, but you'll need to manually add the .svc file and the Web.config. I have done this several times:

    1. Create a folder (I normally put mine in the wwwroot folder of inetpub, but you can put it wherever you desire).
    2. Create a bin folder in the folder you created in step 1, and put the WCF service library and any other required assemblies in it.
    3. Add a .svc file with the appropriate markup in the folder created in step 1.
    4. Add a Web.config with the appropriate service model configuration in the folder created in step 1.
    5. Create an application in IIS that points to the folder you created.

    Now you have an IIS-hosted instance of your service. You can then use another copy of the WCF service library for your Windows-Service hosted instance.

    • Marked as answer by KeokiStevenson Thursday, November 14, 2013 5:32 PM
    Thursday, November 14, 2013 5:32 PM

All replies

  • I have never seen WCF Service Library ever being used in an ASP.NET Web service. But that's not to say that it can't be used. However, you should explore the Web Service Factory. 

    http://servicefactory.codeplex.com/

    Wednesday, November 13, 2013 6:54 AM
  • Thanks I'll take a look at that. Links where an ASP.NET Web Application was used are provided in the links above. 

    Thanks again.
    Wednesday, November 13, 2013 6:55 PM
  • Basically since it is a library, that is all it is. I need to do more to be able to host it.

    http://stackoverflow.com/questions/19944606/combining-wcf-service-library-and-wcf-service-application

    A WCF Service Library has to be hosted in order to be used - you can host it in IIS, a Windows Service or some self-hosted option (like a console app, WinForm, WPF, etc).

    In the last two links you provide, they're demonstrating how to host the library in an ASP.NET service application, but you don't have to use that project template to host it. It's simply one option out of several.

    You can create an IIS-hosted implementation of your class library without using a VS project template, but you'll need to manually add the .svc file and the Web.config. I have done this several times:

    1. Create a folder (I normally put mine in the wwwroot folder of inetpub, but you can put it wherever you desire).
    2. Create a bin folder in the folder you created in step 1, and put the WCF service library and any other required assemblies in it.
    3. Add a .svc file with the appropriate markup in the folder created in step 1.
    4. Add a Web.config with the appropriate service model configuration in the folder created in step 1.
    5. Create an application in IIS that points to the folder you created.

    Now you have an IIS-hosted instance of your service. You can then use another copy of the WCF service library for your Windows-Service hosted instance.

    • Marked as answer by KeokiStevenson Thursday, November 14, 2013 5:32 PM
    Thursday, November 14, 2013 5:32 PM