Combining a WCF Service Library and a WCF Service Application

Thanks to Qaru and a few other sites, I understand the difference between WCF LIbrary and WCF application templates.

In short, a library is a DLL that allows you to use several types of hosting. It does not have a .svc file. Although the Service Applications template is created specifically with IIS in my .svc file.

I read that the WCF Service Library is the best way because it is the most flexible. But I NEVER see instructions on how to do this other than using the WCF service application template.

Is it difficult to switch from WCF Service Library to hosting in IIS from scratch? I have two books on WCF, and I read numerous articles, and none of them describes how to create an svc file using only the WCF service library and No Service WCF Service Application. Why?

Nigel Shaw also mentions the following link that there are restrictions on the use of the Library option. What is the purpose of the WCF library?

Basically what I want to do is host the WCF service on both IIS and the Windows service. Thus, it seems that a combined path is the best way. However, I am trying to find out why there are no more instructions for using the WCF Services Library.

Ok, I found a couple of articles that seem to use the ASP.NET web application and will tell 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 necessary? And if I add the svc file, it will be placed in the wwwroot directory (it seems where the WCF service application puts it in the .svc file?

Thanks!

+6
source share
1 answer

For use, a WCF service library must be hosted, which you can host in IIS, a Windows service, or some independent version (for example, a console application, WinForm, WPF, etc.).

In the last two links that you provide, they demonstrate how to host the library in an ASP.NET service application, but you are not using to use this project template to place it. This is just one of several options.

You can create an IIS embedded class library without using the VS project template, but you need to manually add the .svc file and the Web.config file. I have done this several times:

  • Create a folder (usually I put mine in the wwwroot inetpub folder, but you can put it wherever you want).
  • Create the bin folder in the folder created in step 1, and put the WCF service library and any other necessary assemblies in it.
  • Add the .svc file with the appropriate markup to the folder that you created in step 1.
  • Add Web.config with the appropriate service model configuration to the folder that you created in step 1.
  • Create an application in IIS that points to the folder you created.

You now have an instance of IIS. You can then use another copy of the WCF services library for your instance hosted on Windows-Service.

+8
source

Source: https://habr.com/ru/post/957967/


All Articles