views:

1036

answers:

2

When hosting a WCF service on IIS you have an option of manually configuring the endpoint or declaratively by means of WebServiceHostFactory. It doesn't seem to be that difficult to manually create the endpoint so I figured I would ask.

  • What are the benefits of using WebServiceHostFactory?
  • Are there any performance implications to dynamically creating the endpoints?
+2  A: 

Can you clarify : are you asking specifically about WebServiceHostFactory (emph: "Web")? Or just the difference between IIS hosting it vs starting your own server through code?

WebServiceHostFactory is new in .NET 3.5, and supports some of the newer AJAX/JSON stuff.

Actually, within IIS (using .svc), you are already using a ServiceHostFactory - simply the default one shipped with WCF. You can write your own factory if you want, and I've done this in the past to create a factory that only listens on https (I had an issues on a farm hosting multiple sites, where it couldn't identify the correct site for http, but https was fine - so I completely disabled http via the factory).

Performance shouldn't be any different as long as you don't go mad and listen on 200 end-points...

Generally, manually creating the server is used when you are hosting the server in (for example) a windows service. IIS is fine for some things, but app-pools get recycled, so aren't ideal for a server that needs to retain long-lived state. IIS has the advantage of being much easier to configure, especially with security (SSL etc) and compression.

Marc Gravell
Yes, I am specifically asking about WEB service host
jdiaz
A: 

I am definitely not an expert (yet), but cons that come to mind are:

Pro:

  • effortless setup of REST services from scratch.
Teun D