Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of WCF Service Library?

Tags:

.net

wcf

What is the purpose of WCF Service Library? I understand if you build an IIS hosted service you create a web project, if self-hosted - create an .exe.

What is a real life scenario to use WCF as DLL?

like image 751
Vitalik Avatar asked Sep 14 '09 18:09

Vitalik


People also ask

What is WCF service library?

The application that references/hosts the class library will have its own web/app. config which is the one that is actually used. You can host a WCF service library in IIS by generating the . svc files by hand or using file-less activation, in which case you would be using a web. config and not app.

What is the difference between WCF service library and WCF service application?

The major difference is that the WCF Service Application has a . svc file, whereas the WCF Service Library does not have a . svc file. Suppose we want to host this service application in IIS, then you need to specify for IIS the execution runtime environment requirements.

What is the need for the activation or hosting of a WCF service?

WCF uses the listener adapter interface to communicate activation requests that are received over the non-HTTP protocols supported by WCF, such as TCP, named pipes, and Message Queuing.

What is the use of SVC File in WCF?

svc file contains a WCF-specific processing directive (@ServiceHost) that allows the WCF hosting infrastructure to activate hosted services in response to incoming messages. The most common syntax for a . svc file is in the following statement. It consists of the @ServiceHost directive and a single attribute, Service .


1 Answers

While it's true that creating a WCF service as a class library gives you more flexibility, that flexibility comes at a cost, and it's a mistake to assume that the more flexible solution is always the preferred solution, or that the less flexible solution is childish or only suitable for "simple instructional purposes".

The vast majority of WCF services are hosted as web services and will never be deployed any other way.

Here are three advantages of using a WCF service application as opposed to a WCF class library:

  1. If you create your web service as a class library the configuration files will be app.config files rather than web.config files. App.config files don't natively support multiple configuration files and config transforms the way web.config files do. If you want config transforms on your app.config files you have to use a third party solution such as Slow Cheetah.

  2. When it's time to publish your site, if you use a WCF service application you can take full advantage of Web Deploy (http://www.iis.net/downloads/microsoft/web-deploy) which is a powerful and flexible way to publish your solution to IIS.

  3. If you decide to automate your build and deploy for continuous integration with TFS there will come a time when you'll want to automate the publishing of your service. If you use a WCF service you can configure TFS to run Web Deploy, which will merge your web.config files according to the target build configuration, perform incremental publish, enable publishing without administrator rights on the server and other benefits. If you use a WCF class library then you will have to write a custom workflow solution to merge the app.config files, use xCopy for deployment, and generally have a tougher time automating the deployment.

In summary the more flexible solution, as is often the case, comes at the cost of losing specific tool support. If, like most WCF service solutions, your application will always be hosted in IIS, you might consider taking advantage of this support by using a WCF service application as opposed to a WCF class library.

like image 160
Nigel Shaw Avatar answered Oct 02 '22 16:10

Nigel Shaw