What are the various methods of hosting a WCF service? - c#

What are the various methods of hosting a WCF service?

There are four common ways, all of which are outlined nicely on MSDN: Hosting WCF Services.
Hosting in IIS.
Hosting in WAS.
Hosting in a Windows service.
Hosting in an application (aka "self-hosting").

For right now, everything that's been said is correct.
Hosting in IIS6 only support HTTP protocols and "on-demand" activation
Hosting in IIS7 / WAS (only on Vista / Server 2008 and up) supports all protocols and "on-demand" activation
Self-Hosting in a console app or Windows service supports all protocols, but doesn't support on-demand activation (e.g. your service must be up and running all the time, it cannot be magically activated when a request comes in)
What's not been mentioned is what the .NET 4.0 wave later this year (2009) will offer - there's a new add-on server component called Dublin which is said to offer a rich and managed hosting environment for both WCF services as well as WF workflows.
Marc

You can host it in an IIS application or in your own executable. Typically the executable would be a windows service application.

Any Windows process can be used to host a WCF service. There are practically no restrictions on this - a process can host multiple WCF services and the same WCF service type can be hosted across multiple processes simultaneously.
From Juval Lowy's book Programming WCF Services, hosting can be provided by
Microsoft Internet Information Server (IIS)
Self-hosting within a Windows Forms application, Windows service, or console app
Windows Activation Service (WAS)

Related

WCF: Difference between hosting in IIS and WIndows service

WCF service can be hosted both in IIS and in Windows service. What are differences? Is there any benefit hosting in Windows service than IIS?
Check out the documentation: https://msdn.microsoft.com/en-us/library/ms730158%28v=vs.110%29.aspx
It is awesome!
And the answer to your questions depends on what kind of application you are building and other requirements on the application/environment...!
Here are some differences (Features of IIS.. Copied from the link provided by #Jocke).
You lose all of the features of IIS (logging, application pool scaling, throttling/config of your site, etc.)...
You have to build every single feature that you want yourself HttpContext?
You lose that since ASP.NET provides that for you. So, I could see that making things like authentication much harder WebDeploy?
IIS has some nice specific features in 8 about handling requests and warming up the service (self-hosted does not)
IIS has the ability to run multiple concurrent sites with applications and virtual directories to advanced topics like load balancing and remote deployments.
If your WCF serivce is self-contained, like a data service, just host it in IIS. Drawback: you'll have to install and configure IIS.
If your WCF service is more of an API or IPC mechanism, used to let other applications talk to your application, it makes more sense to let your application self-host the WCF service, and for that a Windows Service usually is the more sensible approach. Drawbacks: you'll have to install your application as Windows Service, and configure that your application may listen on its configured port.
Please note that self-hosting is not constrained to Windows Services.

How to host WCF web service over the internet?

I work as a C# developer and we have many .NET web services that we use. I am doing some at home development and want to do something similar. I have a database (SQL Server 2012) on a home PC running Windows Server 2012 with IIS 8 installed. I have created a WCF web service in Visual Studio (C#) and it compiles to a .svc file. This just facilitates data exchange between my SQL Server Database and the application I am writing.
I am unfamiliar with how to host the WCF service so that the Windows Form application that I am writing that will be installed on many non-local machines can access it. I figured a WCF service would be the best choice for accessing my database for the WinForm application over the internet.
I also have a domain with a basic Windows package on 1&1.com leftover from a previous project if that helps.
Can anyone give me some steps to get my WCF service hosted so it can be accessed over the internet? Please ask if I forgot to list any needed information.
Two common ways are to host your WCF service from IIS, or to self host it yourself from within a simple wrapper program that acts as a TCP server.
See http://msdn.microsoft.com/en-us/library/ee939285.aspx
The simplest way is to setup IIS and just publish your services like you would a web application; your service will exposed over http/https. Use an appropriate binding like wsHttpBinding or BasicHttpBinding depending on your security needs. Read up to understand the different bindings and what each does and does not support.
In order to host WCF via IIS, at least on Windows Server 2003 and 2008, make sure you follow the install steps, such as adding .NET 3.5.1 / WCF options on older platforms. I believe Server 2012 includes it within .NET 4 framework, but I haven't yet done it on 2012.
Google "WCF hosting IIS" for steps / setup guides.
There are also hosting providers that specifically provide WCF hosting solutions, though I'm pretty sure your current provider, since it supports IIS, should do fine.

Access windows service / WCF service from other machine on LAN

Please bear with me as I am beginner to Windows service / WCF service. After much research I have not been able to find satisfactory solution to my problem. Let me describe my problem in brief:
I want to run one Windows service / WCF service on a machine on LAN. I want to make that service to be consumed by applications running on another machines on the LAN, provided following conditions must be satisfied :
1) I should not need to host Windows service / WCF service to IIS.
2) The URL of service should be configurable in the applications running on other machines on LAN. I should not have to hard code the URL anywhere in those applications (e.g. in App.config or so). Service URL should be accepted from the application user. At the best, the application should find the machine on which the service is running and should call the service from there.
(As a side note, the applications running on other machines are in-browser Silverlight applications.)
Is it a tall order? If not, which of the Windows service and WCF service will suit my requirements? Please provide me any resource if you have.

C# Windows Service latest technology

All,
I have been writting Windows Services for a while in C# deriving from ServiceBase.
So far my services are hosted in servers where they usually listen to message queues and process messages.
Is there a new way of creating such services in WCF ?
Thanks,
MK
Yes. Check out Windows Process Activation Services.
From what I understand, it's very much like how you used to host remoting objects under IIS, but with WAS, you don't need to involve the whole huge IIS stack like you used to.
Microsoft Message Queuing would seem to be what you'd want though there are some offshoots like BizTalk Server that may use similar stuff. Just to toss out an idea or two.
I've started using an open source project called TopShelf to easily create applications that run as either a Windows Service or a console app for debugging.
I've also been hearing a lot about Windows Server App Fabric. Here is a quick blurb from the App Fabric white paper.
AppFabric Hosting Services (originally code-named “Dublin”) doesn’t create some entirely new hosting infrastructure. Instead, it builds on what’s already provided by Internet Information Services (IIS) and Windows Process Activation Service (WAS). On this foundation, AppFabric Hosting Services adds extra capabilities for running and managing WCF services, including workflow services. Figure 7 illustrates this idea.
Windows App Fabric Home

Windows Activation Service on Windows 2003

I know (Windows Activation Service) WAS is advertised as part of Windows 2008/Vista/7 but since it appears under .NET 3.5 framework components in Control Panel Windows Components, I was wondering if anyone knows/has managed to run in under Windows 2003 as well.
I'm trying to host a WCF server in WAS under Windows 2003 (written in .NET C#)
Alternatively, does anyone know of any good open source application servers out there that can be used to host .NET servers? (TomCat for .NET?!)
WAS is a part of IIS7, which is available on Vista and Win Server 2008 and up only.
On Win Server 2003, you can either host your WCF service in IIS - which limits you to just http (basicHttp or wsHttp), or - my preferred way - you can host your WCF service yourself.
Typically, you would host your WCF service in a console app for testing/debugging purposes, and then put it inside a Windows NT Service for production - this runs around the clock, with no one logged in, and it supports ALL the WCF bindings (not just http, but also Net.TCP, NetNamedPipe, MSMQ and so on).
Marc
You can always roll your own WCF host. I've used this concept as an example.
http://www.codeproject.com/KB/WCF/generic_wcf_host.aspx
You can host a WCF service in IIS on Windows 2003, if you use basichttpbinding or wshttpbinding.
You could also host a WCF service as a windows service on windows 2003.
WAS is not available on Windows 2003.

Categories